title: Django Apache mod_wsgi 500
body: <p>I have a Django application deployed on CentOS.  Here is what my httpd.conf file looks like:</p>
  
  <pre><code>WSGISocketPrefix /var/run/wsgi
  &lt;VirtualHost *:80&gt;
  
      WSGIDaemonProcess safe python-path=/usr/lib/python2.6/site-packages
      WSGIProcessGroup safe
      WSGIScriptAlias / /opt/safe/safe/wsgi.py
  
      &lt;Directory /opt/safe/safe/&gt;
          Order deny,allow
          Allow from all
       &lt;/Directory&gt;
  &lt;/VirtualHost&gt;
  </code></pre>
  
  <p>EDIT: This is my <code>TEMPLATE_DIRS</code></p>
  
  <pre><code>TEMPLATE_DIRS = (
      # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
      # Always use forward slashes, even on Windows.
      # Don't forget to use absolute paths, not relative paths.
      "/opt/safe/static/templates",
      "/var/www/html/static/templates",
  )
  </code></pre>
  
  <p>EDIT: This is my Admin/Emailing setup:</p>
  
  <pre><code>ADMINS = (
  # ('Your Name', 'your_email@example.com'),
  ('David', 'david@localhost'),
  )
  
  SEND_BROKEN_LINK_EMAILS = True
  
  DEFAULT_FROM_EMAIL = 'david@localhost'
  SERVER_EMAIL = DEFAULT_FROM_EMAIL
  </code></pre>
  
  <p>In my templates directory, I have defined a custom <code>500.html</code> file.  When I set my <code>settings.py</code> to have <code>DEBUG = False</code>, I cannot get anywhere on my site without seeing this custom 500.html page.</p>
  
  <p>What's even more strange is the fact that there are no errors in the log files - so I am unsure of where to look or how to proceed.  I know it can see the templates because of my custom 500.html file, but I am not sure what is causing the 500 Internal Server errors.</p>
  
  <p>EDIT: After further configuration, I managed to get some errors output (thanks to @Matt Stevens), here is the log output:</p>
  
  <pre><code>Traceback (most recent call last):
  File "/usr/lib/python2.6/site-packages/django/core/handlers/base.py", line 89, in get_response
  response = middleware_method(request)
  File "/usr/lib/python2.6/site-packages/django/middleware/common.py", line 55, in process_request
  host = request.get_host()
  File "/usr/lib/python2.6/site-packages/django/http/__init__.py", line 223, in get_host
  "Invalid HTTP_HOST header (you may need to set ALLOWED_HOSTS): %s" % host)
  SuspiciousOperation: Invalid HTTP_HOST header (you may need to set ALLOWED_HOSTS): [my ip address]
  </code></pre>