[Answer]-Unable to determine cause of HTTP 500 in apache with mod_wsgi

0👍

I finally determined the problem. I’m using LDAP for authentication and sometimes the ldap server would time out for a user that was not in the LDAP directory. For whatever reason, this was causing the 500 to be returned. I have that user defined in a .htdigest file and had set my AuthBasicProvider to “ldap file”. After I switched that around to “file ldap”, I haven’t seen the problem since.

👤Tommy

1👍

Django will intercept unhandled exceptions in your code itself and convert them to 500 responses and doesn’t propagate the exception up to the WSGI server. Thus neither the WSGI server or your wrapper will see them if that is what is occurring.

You need to configure Django to log details of such errors. One way is to set ADMINS and mail configuration so it can email them to you. The other way is to set up the logging module properly with Django so it will redirect logged messages to stderr and into the Apache error log. Have a look through the Django documentation for more information.

Leave a comment