Forums

After changed DEBUG = True to False, the website runs into 502 error page

Today, we found that there was error page displayed on our website when customers submit registration page, and the error page was generated by the hosting server. It displayed all server setting information with the suggestion "You're seeing this error because you have DEBUG = True in your Django settings file. Change that to False, and Django will display a standard 500 page."

Then we followed the suggestion and changed " DEBUG = True" to " DEBUG = False", and saved the file and reloaded the app, but the site no more runs normal. It displays the error: "Error code: 502-backend". Even we changed it back to " DEBUG = True", it still shows the same 502 error page.

Before we made the change, the website was okay except when users submit the registration page. But after we did change, the entire site (all webpages) displays 502 error.

We want the site back as soon as possible. Please help us and let us know what causes the problem and how to fix it. Any help is highly appreciated.

It has nothing to do with your change. I am experiencing the same issue. it's something on their end.

Apologies, one of our web servers had a problem. It should be fixed now.

Thanks, giles. The site is up now.

Thanks for confirming that!

Just as some background so that you know what the underlying problem is: our current WSGI server manager has a bug. Under certain circumstances, it can get stuck in a loop where running web apps work, but if you reload them -- or if they were shut down due to inactivity and needed to be restarted because someone was visiting them -- they don't start up correctly. This shows itself as a 502-backend error. (It's worth noting that not every instance of a 502-backend is a result of this bug -- it's a general "this web app isn't working" error, and can also be caused by sufficiently low-level bug in your own code, or could be caused by other errors in our backend [though this is the only backend error on our side we're aware of right now].)

We believe that the bug is triggered when people put an app.run() or equivalent in their web app -- that is, if instead of creating a WSGI server, they try to run something that will listen for incoming connections. Doing that isn't expected to work, but the fact that it causes a series of secondary failures that affect other people on the same server is the major problem here.

To be clear -- I'm not giving this detail as an excuse -- it's PythonAnywhere's problem, and we need to fix it. But hopefully the above makes it clear that it's quite an involved problem and is caused by third-party code, which is making it harder to track down and fix.

Hi Giles,

Thanks for the detailed explanation. Please keep us updated on the progress with this issue as I plan to slowly migrate more and more of my projects to PythonAnywhere. Please thank the team on my behalf for all the hard work you guys do.

My app is crashed with 502. Reload button does not bring the app back up.

Exact same problem with my app

On the case...

Will post updates on this thread.