I had my web2py site working just fine. When I restarted it all I get is this bad gateway problem. If I`m not mistaken the last alteration I made to my code was some minor update to two image links. Any ideias? Tks!
I had my web2py site working just fine. When I restarted it all I get is this bad gateway problem. If I`m not mistaken the last alteration I made to my code was some minor update to two image links. Any ideias? Tks!
I changed back my code, and the links seemed to be the problem. Working just fine. Tks anyway!
very strange... normally there wouldn't be any relationship between some image links and a 502 error. you migth try putting them back again, as an experiment?
I am having a similar problem and isntead of creating a new thread I thought I would post here.
I get 502 errors often on my app. I see them when I pull the latest code from github and refresh the code. When I go to view my app I will often see a 502 error. I have to re-refresh the code and it is fine.
Users are complaining of seeing 502 errors on my site often. I have a script where they upload an excel file and then the scripts uses xlrx on it to calculate results on their data. Some users are getting 502 errors sometimes when they upload. I am not sure what causes it or how to fix it.
The 502 is really just a generic error saying "something went very wrong with your web app". It can appear when we have problems on PythonAnywhere generally, but it can also happen when something goes wrong inside your code -- it's often hard for our system to distinguish between the two cases.
When you say
I see them when I pull the latest code from github and refresh the code. When I go to view my app I will often see a 502 error. I have to re-refresh the code and it is fine.
Do you mean that you've hit the "Reload" button on the Web tab, you see the error, and you have to hit the "Reload" button a second time to fix it?
Sometimes, if you view the web app after you've hit the reload button but before the "spinner" icon next to it has disappeared, it can get into a broken state. web2py seems particularly prone to this problem. Are you using web2py?
Alternatively, if you're not hitting the "Reload" button, then that could be the problem -- if you just pull new code from github and don't reload the app, you've basically taken away the code it was running, so it's likely to get confused.
Regarding the other problems:
Users are complaining of seeing 502 errors on my site often. I have a script where they upload an excel file and then the scripts uses xlrx on it to calculate results on their data. Some users are getting 502 errors sometimes when they upload. I am not sure what causes it or how to fix it.
That might be related to speed -- if your web app has views that take more than 2 minutes to run, then our system is likely to assume that it's crashed and kill your processes. Do you think that might be the problem here?
Yes I am referring to the "Reload" button when I say "refreshing the code". I didn't go back to get the exact name. I am 99.9% sure I wait every time till the spinner stops before refreshing the website but still see the 502. I am using Flask not web2py.
I have my doubts that the users are waiting 2 minutes before seeing this error. I would be surprised since the xls files they upload are small and so are the calculations. I am going back to the users to find out if it always happens, sometimes happens etc.
OK, looking forward to hearing more. Any possibility that it's correlated with times that your app is particularly busy?
I doubt I am that popular.
The 502 error in the second case seems to be a result of xlrd when users enter data that is supposed to be a time but is not in the excel time format. So I will have to look at their docs on how to convert and see if that solves it.
Interesting. If you're getting a 502 triggered by a specific kind of processing then that suggests that either the processing is crashing the worker process or it's locking it up completely so that it no longer responds to requests. Probably more likely to be the latter; if your processes crash then our system will automatically restart them, whereas if they lock up it normally won't, at least for a few minutes (we have a ten-minute timeout after which they would normally be restarted).
hi there, just for anyone else coming across this thread from a search, we have a page of tips on dealing with 502 bad gateway errors on pythonanywhere now!