Flask debug=True does not work when going through uWSGI Flask debug=True does not work when going through uWSGI flask flask

Flask debug=True does not work when going through uWSGI


This question is old, but I'll post this for future reference...

If you want to get the werkzeug error page to work with uwsgi, try using werkzeug's DebuggedApplication middleware:

from werkzeug.debug import DebuggedApplicationapp.wsgi_app = DebuggedApplication(app.wsgi_app, True)

That should do the trick but DO NOT FORGET to do this ONLY in development environments.


According to the Flask mailing list you cannot use Flask's debug option with uWSGI, because it's not to be used in a forking environment.

You see 502 because flask/werkzeug do not send any data to the webserver, so nginx will returns a 502.

You can emulate the debugger using --catch-exceptions option in uWSGI (but please do not do it in production)

So, the reason you're seeing 502s will be because of that. The fix would be to add --catch-exceptions to uWSGI on execution.


The problem is uwsgi does not call app.run(). It calls app(). So instead you can do this:

from flask import Flaskapp = Flask(__name__)app.debug = True