Truncated or oversized response headers received from daemon process
Asked Answered
E

10

15

I recently migrated a python django application from a debian system to a redhat enterprise distribution. The application is hosted using httpd, mod_wsgi and running in a venv in an daemon process. On large requests I now get following error message in the log file:

"Truncated or oversized response headers received from daemon process" 

I have never experienced anything like this and Google is not the key here as well. I checked configuration of apache, but no config is related to response headers in there.

My httpd.conf configuration looks like this ( pretty standard):

WSGIPassAuthorization On
WSGIScriptAlias / /var/www/myapp/wsgi.py
WSGIDaemonProcess my.name python-path=/path/to/myapp/:/path/to/venv/lib/python2.7/site-packages display-name=%{GROUP}
WSGIProcessGroup my.name

Does any Guru have a hint in which direction I should look?

Eladiaelaeoptene answered 18/7, 2014 at 15:47 Comment(0)
E
1

Turned out to be not the actual problem. The problem was lying deeper, as I changed Cairo to CairoCffi and the RSVG-Handler couldn't deal with the Context-Object coming from Cffi. No my actuall problem is having an up-to-date python lib that allows me to convert svg into png. Using svg2png from CairoSVG isn't working for me. I get an

cairo returned CAIRO_STATUS_NO_MEMORY: out of memory

Error, which I'm sure of, that it does not tell the truth again and the problem lies somewhere else. But lets see.

Eladiaelaeoptene answered 22/7, 2014 at 6:56 Comment(1)
Do you have SELinux extensions enabled? That can cause strange memory errors in some circumstances.Asel
O
8

We recently ran into this issue, and after days of vigorous ugoogleizing and massive headache, we discovered that we were using psycopg2-binary as our database connector dependency (I know, newbs)! It states right in their documentation not to use the package in a production environment.

We did add all the other proposed answers such as adding 'WSGIApplicationGroup %{GLOBAL}' to our settings (which we kept), but all of them alone and together didn't solve the issue.

We also found that other C libraries like numpy, cause issues.

Hope this helps someone some day.

Django Webfaction 'Timeout when reading response headers from daemon process'

http://initd.org/psycopg/docs/install.html#prerequisites

Orlantha answered 25/6, 2019 at 12:18 Comment(6)
Thanks... this worked for me. uninstalled psycopg2-binary and installed psycopg2Cyb
this should be accepted answer. worked for me as well!Terwilliger
Reinstalling psycopg2-binary worked for me. Thanks!Dodecagon
Just doing 'pip install psycopg2' requires that prerequisites be installed by 'apt' first, but then you'll have a working psycopg2 WITHOUT psycopg2-binary which causes this bewildering problem. See psycopg.org/docs/install.html#prerequisitesHomesick
I had this error come in random (probably because of numpy) and crash my site. I just did what you said and I don't know if it works. Do you have any idea on how I could try to reproduce the error ?Hohenstaufen
@Hohenstaufen I don't fully understand your question. You got the error, so you implemented the fix, and you don't know if it works, but you want to reproduce the error?Orlantha
A
6

The code used from Apache by mod_wsgi applies a limit on the size of a single response header returned from mod_wsgi daemon mode processes. This would result in a really cryptic error message from Apache which didn't at all point to the problem. From memory the previous error was:

Premature end of script headers

The size limit was also hard coded in Apache and couldn't be changed. This has caused problems for some Python web applications such as Keystone in OpenStack which generates very large authentication headers.

In mod_wsgi 4.1+, the reliance on the Apache code has been removed and the limit is now configurable. The error message is also more specific as you have seen.

The default maximum header size for what is returned from mod_wsgi daemon mode, that is header name and value, is about 8192 bytes. You can override this by using the header-buffer-size option to WSGIDaemonProcess.

Can you indicate what application and what header was so large that the limit was reached as would like to know what other Python web applications besides Keystone are generating such large headers if is a commonly used application.

A second possibility, deriving from the 'truncated' reference in that message, is that your mod_wsgi daemon process crashed. You don't say though that you saw a 'Segmentation fault' or similar message indicating that a crash occurred. Check for that and if there are other messages in the error log at the time, then indicate what they were and can look at that as the primary problem.

Asel answered 19/7, 2014 at 20:35 Comment(9)
I will check this tomorrow morning. The problem is caused by Django, I grab svg-xml from some statistical graphs on the webpage and push them to django (1.6.5), where I use Cairo and xhtml2pdf to convert them to png files and put into a pdf file, which is the response. I have run this app on a WSGIDaemonProcess many times before and never had problems. First time this happens when I test it on a new RHEL 6 server. Python is 2.7.3 and Apache is 2.2.Eladiaelaeoptene
OK. No success! I increased header-buffer-size=32768 first to approx. 16000 and now 32768. No changes. Restarted apache, removed .pyc files of wsgi.py and so on. No success. For more info, here is the wsgi.py I use:Eladiaelaeoptene
import os os.environ.setdefault("DJANGO_SETTINGS_MODULE", "app.settings") from django.core.wsgi import get_wsgi_application application = get_wsgi_application()Eladiaelaeoptene
Sorry, my fault. I guess this is an success. I didn't close the app on restart, so the process was not reloaded. As far as I see it works. Let me test tomorrow, then I give the OK to mark as resolved. Thank you very much Graham. Saved me a hell of a time.Cheers KartopeteEladiaelaeoptene
If this is the response header size, can you clarify what the header was for that was so large.Asel
Hang on. I guess it was false alarm yesterday. I checked and I have the same problem. I need more tim eon this. As well I need to see how to print the response header as the one seen in the browser is coming from an internal server error page from django, regardless on the debug mode of django.Eladiaelaeoptene
Just go set 'WSGIApplicationGroup %{GLOBAL}' and see if the issue goes away. It is more likely the process is crashing and you just aren't noting the error message indicating that from the Apache error logs.Asel
Also make sure you go read code.google.com/p/modwsgi/wiki/DebuggingTechniquesAsel
@GrahamDumpleton where do you add "WSGIApplicationGroup %{GLOBAL}" in the config file? Does the order matter?Culp
E
1

Turned out to be not the actual problem. The problem was lying deeper, as I changed Cairo to CairoCffi and the RSVG-Handler couldn't deal with the Context-Object coming from Cffi. No my actuall problem is having an up-to-date python lib that allows me to convert svg into png. Using svg2png from CairoSVG isn't working for me. I get an

cairo returned CAIRO_STATUS_NO_MEMORY: out of memory

Error, which I'm sure of, that it does not tell the truth again and the problem lies somewhere else. But lets see.

Eladiaelaeoptene answered 22/7, 2014 at 6:56 Comment(1)
Do you have SELinux extensions enabled? That can cause strange memory errors in some circumstances.Asel
A
1

I had an issue with this in CentOS 7 server when deploying Django using httpd with mod_wsgi 4.5.4. I had to revert back to using mod_wsgi 4.3.2 which solved my problem.

Applied answered 12/8, 2016 at 20:20 Comment(1)
Are you setting the application group to %{GLOBAL}? It is more likely your daemon mode process is crashing. See modwsgi.readthedocs.io/en/develop/user-guides/…Asel
P
1

I have installed filebeat which changed my ssl version so that psycopy2 needs to be updated and the error was Truncated or oversized response headers received from daemon process

Do the following:-

Uninstall your psycopy2 package using pip. I am using pip3 because my python version is 3.6.8

sudo pip3 uninstall psycopg2

Reinstall psycopy2 using pip.

sudo pip3 install psycopg2

Before psycopg2-2.7.4 now psycopg2-2.8.3

Periwig answered 25/9, 2019 at 7:43 Comment(0)
P
0

I suddenly had this same problem after an update. The next update fixed the problem... I run arch, as of the date of this post, the WSGI version in repo works.

Preview answered 23/2, 2015 at 6:33 Comment(0)
C
0

I had the same error message "Truncated or oversized response headers received from daemon process '...': /var/www/dev.audiocont.com/index.wsgi" in my Django project (without any other error message).

My error was that I changed the virtual environment and forgot to adapt the Apache settings "dev.conf" to the new venv path.

Chicle answered 9/8, 2019 at 6:48 Comment(0)
R
0

Change Deadlock time out in httpd.conf I tried everything ,none of the answer work for me .Then i change the deadlock timeout and everything works fine now .Server Goes in to idle state for long processing just change the deadlock timeout.

Roper answered 25/4, 2020 at 1:20 Comment(0)
P
0

I got into the same problem "Truncated or Oversized Response Headers".

I Resolved it by adding,

"WSGIDaemonProcess test user=apache group=apache processes=1 display-name=%{GROUP} header-buffer-size=65536" 

in app.conf/httpd.conf depends upon your configuration file.

Based on your server's RAM size change the Processes and header-buffer-size. Default is header-buffer-size is 65536

Perfect answered 5/9, 2021 at 18:40 Comment(0)
C
0

For me SQLite turned out to be the problem.

I migrated a Django application with SQLite, on a new server, and this error started appearing, and the HTTP requests hanging.

I manage to solve the issue with:

WSGIApplicationGroup %{GLOBAL}'

But, I wanted to get to the bottom of the problem, as this application was not using any different python modules than other applications on the same server.

I realized that the only difference is the SQLite database, and after migrating from SQLite to Postgres, the problem went away.

In the past, I've had other grievances with using Django with SQLite, so I would advise against using SQLite for anything that needs to go into production.

Canberra answered 5/12, 2022 at 14:39 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.