Copy what you written before submitting (Ctrl+c). That way if you get the "Bad Gateway" error message, you haven't lost it.
Just wait for the site to respond again, then paste (Ctrl+v) what you've written to wherever you were trying to put it.
If the site doesn't respond for a while, paste it into something like Notepad for later.