[Solved]-Django – End of script output before headers


This is covered by the mod_wsgi documentation.


In short, you are likely using a Python extension module which is not implemented to work properly in a Python sub interpreter. That or the extension module is not releasing the GIL properly when doing blocking operations. Both can result in an interpreter deadlock.

Use the solution in the documentation and see if that helps.


<VirtualHost *:80>
    ServerName localhost
    ServerAlias localhost
    ServerAdmin raghav@xyz.com

    <Directory /var/www/mysite/mysite>
    AddHandler wsgi-script .py
    Options +ExecCGI

    DocumentRoot /var/www/mysite
    WSGIDaemonProcess myproject python-path=/var/www/mysite:/var/www/environ/lib/python2.7/site-packages
    #WSGIProcessGroup mysite
    WSGIScriptAlias / /var/www/mysite/mysite/wsgi.py

    WSGIApplicationGroup %{GLOBAL}

    <Directory /var/www/mysite/mysite/>

    order deny,allow
    Allow from all

I also had the same error and I have solved this issue by using this configuration.

Also add the following line to /etc/apache2/apache.config

#WSGIPythonPath /var/www/mysite


I am aware this thread is three years old but I stumbled across it when I had a similar issue so I thought I would add my solution. In my case it was something in the virtual environment that required mod_ssl to be enabled in Apache even though none of the sites used SSL (well they do but it is terminated elsewhere). So

a2enmod ssl
service apache2 restart

Fixed it.

πŸ‘€Paul Turton


After digging through the answers above. I had to set the number of processes from 5 to 1. Also using the multi worker mpm.

LoadModule mpm_worker_module modules/mod_mpm_worker.so
WSGIDaemonProcess music user=apache group=apache processes=1 threads=30  python-path=/srv/www/music/service/venv/lib/python2.7/site-packages
πŸ‘€Pat W

Leave a comment