500 Error without anything in the apache logs 500 Error without anything in the apache logs flask flask

500 Error without anything in the apache logs


Turns out I was not completely wrong. The exception was indeed thrown by sqlalchemy. And as it's streamed to stdout by default, mod_wsgi silently ignored it (as far as I can tell).

To answer my main question: How to see the errors produced by the WSGI app?

It's actually very simple. Redirect your logs to stderr. The only thing you need to do, is add the following to your WSGI script:

import logging, syslogging.basicConfig(stream=sys.stderr)

Now, this is the most mundane logging config. As I haven't put anything into place yet for my application this will do. But, I guess, once the application matures you will have a more sophisticated logging config anyways, so this won't bite you.

But for quick and dirty debugging, this will do just fine.


I had a similar problem: occasional "Internal Server Error" without logs. When you use mod_wsgi you should remove "app.run()" because this will always start a local WSGI server which we do not want if we deploy that application to mod_wsgi. See docs. I do not know if this is your case, but I hope this can help.


If you put this into your config.py it will help dramatically in propagating errors up to the apache error log:

PROPAGATE_EXCEPTIONS = True