Django/WSGI/Apache – How to Debug Errors

djangomod-wsgi

I have a Django 1.11.17 application deployed on Apache 2 and WSGI, Python 2.7.

Apache shows an error "Truncated or oversized response headers received from daemon process"

I have checked the solution given in
WSGI : Truncated or oversized response headers received from daemon process

and WSGIApplicationGroup %{GLOBAL} is in the virtual host file. However the error persists.

Django shell works. Django check returns no errors. Django runserver works. Django log shows no errors.

How can I see the exact error that is making WSGI not working?

Best Answer

There is a debugging mode that you can use provided by mod_wsgi. You can find the documentation here:
https://modwsgi.readthedocs.io/en/develop/user-guides/debugging-techniques.html

However, we found that we were using third-party packages such as numpy or psycopg2-binary that were causing issues. In our case, we were using psycopg2-binary which is a big no no for production apps. We removed it and followed their documentation on pip installation and everything worked. We also added WSGIApplicationGroup %{GLOBAL} to our apache2 server settings.

You may find the psycopg documentation at http://initd.org/psycopg/docs/install.html#prerequisites

Hope this helps.