title: Gateway Timeout Using Django on Apache with mod_wsgi
body: <p>I'm having a problem getting Apache to reply properly. I'm getting a browser error: <code>Gateway Timeout: The gateway did not receive a timely response from the upstream server or application.</code></p>
  
  <p>I know the application is connecting through mod_wsgi to the Django layer, as I've verified queries are occurring in PostgreSQL when the connection occurs, from the Wagtail CMS's middleware running.</p>
  
  <p>The system is running RHEL 7.1, Apache 2.4.6, and mod_wsgi 4.4.21 with Python 3.4 and Django 1.8.</p>
  
  <p>Here's the error in the Apache log:</p>
  
  <pre><code>[Thu Jan 07 13:25:54.554395 2016] [wsgi:error] [pid 17128] [client 128.91.91.123:50664] Timeout when reading response headers from daemon process 'my_classroom-https': /var/www/html/my_classroom/my_classroom/wsgi.py
  </code></pre>
  
  <p>Here's wsgi.py:</p>
  
  <pre><code>import os, sys
  from socket import gethostname
  from django.core.wsgi import get_wsgi_application
  
  sys.path.append(os.sep.join(os.path.abspath(__file__).split(os.sep)[:-2]))
  
  # cpl == Core, Production, Linux..
  if(gethostname()[:3]) == 'cpl':
      os.environ.setdefault("DJANGO_SETTINGS_MODULE", "my_classroom.settings.prod")
  # csl == Core, Staging, Linux.
  elif(gethostname()[:3]) == 'csl':
      os.environ.setdefault("DJANGO_SETTINGS_MODULE", "my_classroom.settings.stage")
  # else use dev settings.
  # cdl == Core, Development, Linux. vag == Vagrant.
  else:
      os.environ.setdefault("DJANGO_SETTINGS_MODULE", "my_classroom.settings.dev")
  
  application = get_wsgi_application()
  </code></pre>
  
  <p>And here's the relevant portion of the Apache config:</p>
  
  <pre><code>LoadModule wsgi_module modules/mod_wsgi.so
  LoadModule ssl_module modules/mod_ssl.so
  
  WSGISocketPrefix /var/run/wsgi
  
  NameVirtualHost *:443
  Listen 443
  &lt;VirtualHost *:443&gt;
  
    ServerName my-python-dev.school.edu
    ErrorLog /var/www/logs/classroom-apache-errors.log
  
    SSLENGINE on
  
    SSLCertificateFile /etc/pki/tls/certs/localhost.crt
    SSLCertificateKeyFile /etc/pki/tls/private/localhost.key
    SSLCipherSuite ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM:+LOW
    SSLProtocol all -SSLv2
  
    WSGIApplicationGroup %{GLOBAL}
    WSGIDaemonProcess my_classroom-https python-home=/var/www/virtualenvs/my_classroom request-timeout=600
    WSGIScriptAlias /classroom /var/www/html/my_classroom/my_classroom/wsgi.py process-group=my_classroom-https
    WSGIProcessGroup my_classroom-https
    Alias /classroom/static/ /var/www/html/my_classroom/static/
  
    LogLevel info
  &lt;/VirtualHost&gt;
  </code></pre>
  
  <p>I've tried a few few things, including increasing the <code>request-timeout</code> parameter of the WSGIDaemonProcess directive to be 600 seconds instead of 60, but it still seems to timeout right around 60 seconds.</p>
  
  <p>Any ideas or help would be greatly appreciated. Thanks.</p>