Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fix " Timeout when reading response headers from daemon process" error when using WSGI with Django and Apache

I have installed Django and created a new project using the following commands:

mkdir trydjango
cd trydjango
virtualenv -p python3 .
source bin/activate
pip install django==2.0.7

When I run pip freeze, I see the following:

Django==2.0.7
pkg-resources==0.0.0
pytz==2018.9

Inside my virtualhost I have the following:

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    ServerName django.mydomain.com
    ServerAlias www.django.mydomain.com
    DocumentRoot /var/www/django.mydomain.com
    ErrorLog ${APACHE_LOG_DIR}/django.mydomain.com.error.log
    CustomLog ${APACHE_LOG_DIR}/django.mydomain.com.access.log combined


    <Directory root/Dev/trydjango/src/trydjango>
           <Files wsgi.py>
                 Require all granted
           </Files>
        </Directory>

    WSGIApplicationGroup %{GLOBAL}
    WSGIDaemonProcess trydjango python-home=root/Dev/trydjango/bin python-path=root/Dev/trydjango/
    WSGIProcessGroup trydjango
    WSGIScriptAlias / /root/Dev/trydjango/src/trydjango/wsgi.py

</VirtualHost>

But when I try to access my domain, it time outs. When I access the Apache error log for the domain the following error message is present:

[pid 12746] [client xx.xx.xx.xxx:60684] Timeout when reading response headers from daemon process 'trydjango': /root/Dev/trydjango/src/trydjango/wsgi.py

How can I fix this timeout problem?

I've chowned wsgi.py to www-data:www-data I've also made the folder the app is in exectuable

Not sure what else to try with this brand new project to get wsgi working.

I found this: Django Webfaction 'Timeout when reading response headers from daemon process'

and added WSGIApplicationGroup %{GLOBAL} to the virtualhost and also to apache2.conf but this didn't fix the problem.

like image 432
Gary Avatar asked Mar 08 '19 10:03

Gary


1 Answers

i just fix a problem like that, but widht flask-wsgi, i think is the same " Timeout when reading response headers from daemon process ", just go to the folder "/etc/httpd/conf.d/"(in centos), in the file of configuration of python-wsgi, in my case "python-wsgi.conf",

Listen 5002 <VirtualHost 192.168.150.62:5002>

ServerAdmin webmaster@localhost
#DocumentRoot /var/www/html
DocumentRoot /home/XXXXXXx/XXXXXXXXX
ServerAlias XXXXXXXXXXXXXX
ServerName XXXXXXXXXXXXXXX

LogLevel debug

WSGIDaemonProcess xxxxxxxxxxxxxxxxx python-path=/home/XXXXX/XXXXXXXXXX:/home/XXXXXX/XXXXXXXXX/venv/lib/python3.6/site-packages
WSGIProcessGroup XXXXXXXXXXXXXXX
WSGIScriptAlias / /home/XXXXX/XXXXXXXXXXXXX/app.wsgi 
WSGIPassAuthorization On
WSGIChunkedRequest On
ErrorLog logs/error-5000-dev.log
CustomLog logs/access-5000-dev.log combined

<Directory /home/XXXXX/XXXXXXXXXXXXXXX>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Require all granted
</Directory>

Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/XXXXXX.com/cert.pem
SSLCertificateKeyFile /etc/letsencrypt/live/xxxxxxxx.com/privkey.pem
SSLCertificateChainFile /etc/letsencrypt/live/xxxxxxxxx.com/chain.pem
SetEnv nokeepalive ssl-unclean-shutdown
TimeOut 18000

look, i put a set property "TimeOut" in the final of the file, i put a big amount of second for test 18000, and works for me, of course, you must restart the service apache,"service httpd restart" after the change. by default is 60 second, if you dont touch it. try thata and tell me if you solved the problem.good luck.!

like image 193
Pedro Orozco Avatar answered Nov 15 '22 06:11

Pedro Orozco