0

I had a working Django app running in RHEL 6 with Apache, mod_wsgi and I have DEBUG = True in my settings.py file.

It seemed to happen out of the blue (no changes were made to the server) when I suddenly get 500 Internal Server Errors when trying to access the web application. There is nothing in the error logs (and I literally mean nothing) for Apache, and even though the DEBUG is set to true in Django, I still only get the 500 page.

I tried adding extensive Django logging by following the thread here, but it doesn't log anything.

Any ideas on how I can get more information on what could be causing the problem?

Community
  • 1
  • 1
lightningmanic
  • 2,025
  • 5
  • 20
  • 41

2 Answers2

0

If you've got debug on and that's working correctly all errors should be displayed.

But regardless you can get Django to email you on any server errors which will be especially helpful in responding to a production environment problem. The docs on error reporting will help, specifically:

At the very least, you’ll need to specify EMAIL_HOST and possibly EMAIL_HOST_USER and EMAIL_HOST_PASSWORD,

I think this is the standard logging but anyway, in your settings.py file make sure that ADMINS = () isn't empty and then check your logging configuration.

While you're using DEBUG mode make sure you don't also have the require_debug_false filter included.

ADMINS = (
    # ('Your Name', 'your_email@example.com'),
)

# A sample logging configuration. The only tangible logging
# performed by this configuration is to send an email to
# the site admins on every HTTP 500 error when DEBUG=False.
# See http://docs.djangoproject.com/en/dev/topics/logging for
# more details on how to customize your logging configuration.
LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'filters': {
        'require_debug_false': {
            '()': 'django.utils.log.RequireDebugFalse'
        }
    },
    'handlers': {
        'mail_admins': {
            'level': 'ERROR',
            'filters': ['require_debug_false'],
            'class': 'django.utils.log.AdminEmailHandler'
        }
    },
    'loggers': {
        'django.request': {
            'handlers': ['mail_admins'],
            'level': 'ERROR',
            'propagate': True,
        },
    }
} 

If you've got all this, then you should get some insight in to your errors.

markwalker_
  • 12,078
  • 7
  • 62
  • 99
0

Turns out it wasn't a Django problem at all but an Apache issue. The Django application is protected with an LDAP authentication service, configured in the Apache configuration files. However, the LDAP server was down, so Apache couldn't contact it.

What still doesn't make any sense is why Apache wouldn't log this problem, even though I have the LogLevel debug set in its configuration files...

lightningmanic
  • 2,025
  • 5
  • 20
  • 41