I’ve been looking through many similar issues but no solution seems to fit my problem so I’m posting this here.
I can’t figure out how to get around the error:
“Truncated or oversized response headers received from daemon process “
My server configuration :
- Apache 2.4.34 (Ubuntu)
- mod_wsgi 4.5.17
- OpenSSL 1.1.1
- Python 3.6
The exact error log that I receive is:
[Tue Mar 19 15:14:43.666649 2019] [wsgi:info] [pid 7988] mod_wsgi (pid=7988): Initializing Python.
[Tue Mar 19 15:14:43.684932 2019] [ssl:info] [pid 7945] [client X.X.X.X:X] AH01964: Connection to child 1 established (server app.com:443)
[Tue Mar 19 15:14:43.762255 2019] [wsgi:info] [pid 7988] mod_wsgi (pid=7988): Attach interpreter ''.
[Tue Mar 19 15:14:43.836994 2019] [ssl:info] [pid 7946] [client X.X.X.X:X] AH01964: Connection to child 2 established (server neuralytics.ai:443)
[Tue Mar 19 15:14:43.967857 2019] [wsgi:error] [pid 7947] [client X.X.X.X:X] Truncated or oversized response headers received from daemon process 'flaskapi': /path/to/subdomain/flaskapp.wsgi, referer: https://subdomain.app.com/register
As you can see LogLevel set to info.
The flaskapp.wsgi :
#!/usr/bin/python3
activate_this = '/var/subdomain/app.com/public/path/to/my/virtualenv/bin/activate_this.py'
exec(open(activate_this).read())
import sys
import logging
logging.basicConfig(stream=sys.stderr)
path = '/var/subdomain/app.com/public/path/to/flask'
if path not in sys.path:
sys.path.append(path)
from main import app as application
application.secret_key = '****'
The .conf file handles several subdomains. The most important part is related to subdomain.app.com :
#WSGIPythonPath /usr/bin/python3
<IfModule mod_ssl.c>
<VirtualHost *:443>
[...]
ServerName app.com
ServerAlias www.app.com
[...]
</VirtualHost>
<VirtualHost *:443>
ServerName subdomain.app.com
DocumentRoot /var/subdomain/app.com/public
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
ServerAlias subdomain.app.com
Include /etc/letsencrypt/options-ssl-apache.conf
WSGIDaemonProcess flaskapi python-path=/var/subdomain/app.com/public/:/var/subdomain/app.com/public/path/to/my/virtualenv/lib/python3.6/site-packages/
WSGIProcessGroup flaskapi
WSGIScriptAlias / /var/subdomain/app.com/public/flaskapp.wsgi
WSGIApplicationGroup %{GLOBAL}
<Directory /var/subdomain/app.com/public>
Require all granted
</Directory>
Alias /static/ /var/subdomain/app.com/public/production/static/
<Directory /var/api/neuralytics.ai/public/production/static/>
Require all granted
</Directory>
SSLCertificateFile /etc/letsencrypt/live/app.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/app.com/privkey.pem
</VirtualHost>
</IfModule>
Chrome Dev output for Response Headers :
HTTP/1.1 500 Internal Server Error
Date: Tue, 19 Mar 2019 15:25:58 GMT
Server: Apache/2.4.34 (Ubuntu)
Content-Length: 627
Connection: close
Content-Type: text/html; charset=iso-8859-1
Chrome Dev output for Request headers :
POST /register HTTP/1.1
Host: subdomain.app.com
Connection: keep-alive
Content-Length: 164
Origin: https://subdomain.app.com
X-CSRFToken: *******
X-Requested-With: XMLHttpRequest
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36
Content-Type: application/json;charset=UTF-8
Accept: */*
Referer: https://subdomain.app.com/register
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.9,fr;q=0.8,es;q=0.7
Cookie: session=******
Does any of you have an idea of how to fix this ?
Also this is my first stackoverflow post so I hope this is detailed enough, let me know if it’s not 🙂
3
Answers
sorry for the late response but I had the same issue and I followed this solution and worked for me.
https://stackoverflow.com/a/56753895/8569520
in my case the problem was with psycopg2 version, I updated it to the latest version and it worked
I did everything that ALL advised. No result. The reason is mysql.connector. Replaced it with pymysql. It’s OK.
I’ve encountered this problem when retrieving data as a result of MySQL query on Fedora 34 with Apache 2.4, MariaDB 10.5, mod_wsgi 4.9, Python 3.9.6, Flask 2.0.1 and mysql-connector 2.2.9.
To solve it I had to set WSGIDaemonProcess
header-buffer-size
parameter in the virtualhost configuration.This parameter has a default value of 32768 bytes, so I’ve increased it.
WSGIDaemonProcess documentation:
https://modwsgi.readthedocs.io/en/master/configuration-directives/WSGIDaemonProcess.html