Apache not serving website - django

My website was running perfectly. Today I found that someone had rebooted the server (which is a virtual machine) and the website is not working from that time.
Apache is set to run automatically, and it is running.
I tried to restart apache and the server again and to turn the firewall off, but still the website is not working and the browser tells me "ERR_CONNECTION_REFUSED"
Apache error log gives these messages when I restart apache and try to open the website:
[Tue Apr 12 16:14:32.275157 2016] [mpm_winnt:notice] [pid 1356:tid 468] AH00424: Parent: Received restart signal -- Restarting the server.
[Tue Apr 12 16:14:32.562277 2016] [ssl:warn] [pid 1356:tid 468] AH01873: Init: Session Cache is not configured [hint: SSLSessionCache]
[Tue Apr 12 16:14:32.563254 2016] [mpm_winnt:notice] [pid 1356:tid 468] AH00455: Apache/2.4.18 (Win32) OpenSSL/1.0.2f mod_wsgi/4.4.22 Python/2.7.11 configured -- resuming normal operations
[Tue Apr 12 16:14:32.563254 2016] [mpm_winnt:notice] [pid 1356:tid 468] AH00456: Server built: Dec 9 2015 12:21:09
[Tue Apr 12 16:14:32.563254 2016] [core:notice] [pid 1356:tid 468] AH00094: Command line: 'C:\\Program Files (x86)\\Apache Software Foundation\\Apache24\\bin\\httpd.exe -d C:/Program Files (x86)/Apache Software Foundation/Apache24'
[Tue Apr 12 16:14:32.563254 2016] [mpm_winnt:notice] [pid 1356:tid 468] AH00418: Parent: Created child process 4928
[Tue Apr 12 16:14:33.040811 2016] [ssl:warn] [pid 4928:tid 364] AH01873: Init: Session Cache is not configured [hint: SSLSessionCache]
[Tue Apr 12 16:14:33.275195 2016] [mpm_winnt:notice] [pid 4928:tid 364] AH00354: Child: Starting 64 worker threads.
[Tue Apr 12 16:15:04.407249 2016] [mpm_winnt:notice] [pid 1688:tid 360] AH00362: Child: Waiting 30 more seconds for 7 worker threads to finish.
[Tue Apr 12 16:15:34.699426 2016] [mpm_winnt:notice] [pid 1688:tid 360] AH00362: Child: Waiting 0 more seconds for 7 worker threads to finish.
[Tue Apr 12 16:15:34.800016 2016] [mpm_winnt:notice] [pid 1688:tid 360] AH00363: Child: Terminating 7 threads that failed to exit.
[Tue Apr 12 16:15:34.800016 2016] [mpm_winnt:notice] [pid 1688:tid 360] AH00364: Child: All worker threads have exited.
[Tue Apr 12 16:15:47.162795 2016] [wsgi:error] [pid 4928:tid 1000] c:\\Python27\\lib\\site-packages\\skimage\\filter\\__init__.py:6: skimage_deprecation: The `skimage.filter` module has been renamed to `skimage.filters`. This placeholder module will be removed in v0.13.
[Tue Apr 12 16:15:47.162795 2016] [wsgi:error] [pid 4928:tid 1000] warn(skimage_deprecation('The `skimage.filter` module has been renamed '
[Tue Apr 12 16:15:47.162795 2016] [wsgi:error] [pid 4928:tid 1000]
[Tue Apr 12 16:17:19.326490 2016] [mpm_winnt:notice] [pid 1356:tid 468] AH00424: Parent: Received restart signal -- Restarting the server.
[Tue Apr 12 16:17:19.452471 2016] [ssl:warn] [pid 1356:tid 468] AH01873: Init: Session Cache is not configured [hint: SSLSessionCache]
[Tue Apr 12 16:17:19.452471 2016] [mpm_winnt:notice] [pid 1356:tid 468] AH00455: Apache/2.4.18 (Win32) OpenSSL/1.0.2f mod_wsgi/4.4.22 Python/2.7.11 configured -- resuming normal operations
[Tue Apr 12 16:17:19.452471 2016] [mpm_winnt:notice] [pid 1356:tid 468] AH00456: Server built: Dec 9 2015 12:21:09
[Tue Apr 12 16:17:19.452471 2016] [core:notice] [pid 1356:tid 468] AH00094: Command line: 'C:\\Program Files (x86)\\Apache Software Foundation\\Apache24\\bin\\httpd.exe -d C:/Program Files (x86)/Apache Software Foundation/Apache24'
[Tue Apr 12 16:17:19.453448 2016] [mpm_winnt:notice] [pid 1356:tid 468] AH00418: Parent: Created child process 3708
[Tue Apr 12 16:17:19.922216 2016] [ssl:warn] [pid 3708:tid 360] AH01873: Init: Session Cache is not configured [hint: SSLSessionCache]
[Tue Apr 12 16:17:21.297269 2016] [mpm_winnt:notice] [pid 3708:tid 360] AH00354: Child: Starting 64 worker threads.
[Tue Apr 12 16:17:22.298284 2016] [mpm_winnt:notice] [pid 4928:tid 364] AH00363: Child: Terminating 57 threads that failed to exit.
[Tue Apr 12 16:17:22.298284 2016] [mpm_winnt:notice] [pid 4928:tid 364] AH00364: Child: All worker threads have exited.
[Tue Apr 12 16:17:22.773888 2016] [wsgi:error] [pid 3708:tid 984] c:\\Python27\\lib\\site-packages\\skimage\\filter\\__init__.py:6: skimage_deprecation: The `skimage.filter` module has been renamed to `skimage.filters`. This placeholder module will be removed in v0.13.
[Tue Apr 12 16:17:22.773888 2016] [wsgi:error] [pid 3708:tid 984] warn(skimage_deprecation('The `skimage.filter` module has been renamed '
[Tue Apr 12 16:17:22.773888 2016] [wsgi:error] [pid 3708:tid 984]
What may cause this problem? or What else I can check?
Thank you very much.

Sounds like your network connection to the VM has problems. Try to telnet into it on port 80. You can find instructions to do this with Google."

Related

Failing on create_engine while using SQLAlchemy on ElasticBeanstalk

I am attempting to deploy a Flask application which uses SQLAlchemy to an AWS ElasticBeanstalk environment. I can deploy and see a running application, but when I attempt to use create_engine to connect to my database the whole thing crashes. I can run the run the whole app locally on a linux vm (including using the database within the ElasticBeanstalk environment.) I can ssh into the app server and print to the terminal.
I think something about how the application runs when being accessed from a browser (via the application url) is causing the problem. I would be immensely grateful if someone can point me in the right direction. I've been working on this problem for 3 days and I'm starting to go nuts.
This is the code I am using to create my session:
from sqlalchemy import create_engine, Column, ForeignKey, Integer, String
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import relationship, sessionmaker
from sqlalchemy.engine.url import URL
import settings
Base = declarative_base()
# establish connection to database
def db_connect():
"""
Performs database connection using database settings from settings.py.
Returns sqlalchemy engine instance
"""
print ".............................................."
print "...Connecting to Database at URL : "
print "...attempting URL(**settings.DATABASE)"
print "... ", URL(**settings.DATABASE)
print "...above should read: "
print "... postgresql://ebroot:42Snails#aa12jlddfw2awrj.cc6p0ojvcx3g.us-east-1.rds.amazonaws.com:5432/ebdb"
print ".............................................."
print "...attempting engine = create_engine(URL(**settings.DATABASE))..."
try:
engine = create_engine(URL(**settings.DATABASE))
print "...Succeeded in creating engine.................."
return engine
except:
print "..................................................."
print "...Failed to create engine in database_setup.py...."
print "..................................................."
raise
def makeSession():
# Establishes a session called session which allows you to work with the DB
try:
print "....trying to create session.................."
engine = db_connect()
print "....succeeded in db_connect().................."
Base.metadata.bind = engine
print "....succeeded in Base.metadata.bind = engine..."
# create a configured "Session" class
Session = sessionmaker(bind=engine)
print "....succeeded in Session = sessionmaker(bind=engine)..."
# create a Session
session = Session()
print ".............................................."
print "...Succeeded in creating session.............."
print ".............................................."
return session
except:
print "................................................."
print "...Failed to create session in application.py...."
print "................................................."
raise
print "finally.... session.close()"
session.close()
This is a snippet from /var/log/httpd/error_log. Lines beggining with "..." are print statements I am using to isolate the issue. I have altered the url I use to get to the database to frustrate the robots. The address I use works perfectly from my local machine and from the terminal when I ssh into the app server.
[Sat Mar 19 20:16:00.159375 2016] [mpm_prefork:notice] [pid 670] AH00169: caught SIGTERM, shutting down
[Sat Mar 19 20:16:01.259575 2016] [suexec:notice] [pid 1077] AH01232: suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Sat Mar 19 20:16:01.270801 2016] [so:warn] [pid 1077] AH01574: module wsgi_module is already loaded, skipping
[Sat Mar 19 20:16:01.273963 2016] [auth_digest:notice] [pid 1077] AH01757: generating secret for digest authentication ...
[Sat Mar 19 20:16:01.274662 2016] [lbmethod_heartbeat:notice] [pid 1077] AH02282: No slotmem from mod_heartmonitor
[Sat Mar 19 20:16:01.274712 2016] [:warn] [pid 1077] mod_wsgi: Compiled for Python/2.7.9.
[Sat Mar 19 20:16:01.274719 2016] [:warn] [pid 1077] mod_wsgi: Runtime using Python/2.7.10.
[Sat Mar 19 20:16:01.276674 2016] [mpm_prefork:notice] [pid 1077] AH00163: Apache/2.4.16 (Amazon) mod_wsgi/3.5 Python/2.7.10 configured -- resuming normal operations
[Sat Mar 19 20:16:01.276690 2016] [core:notice] [pid 1077] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'
[Sat Mar 19 20:16:04.069713 2016] [:error] [pid 1080] ...in settings.py.......
[Sat Mar 19 20:19:53.419659 2016] [:error] [pid 1080] ....trying to create session..................
[Sat Mar 19 20:19:53.419702 2016] [:error] [pid 1080] ..............................................
[Sat Mar 19 20:19:53.419707 2016] [:error] [pid 1080] ...Connecting to Database at URL :
[Sat Mar 19 20:19:53.419711 2016] [:error] [pid 1080] ...attempting URL(**settings.DATABASE)
[Sat Mar 19 20:19:53.419876 2016] [:error] [pid 1080] ... postgresql://user:password#aa12jlddfw2awrj.cc6p9990ojvcx3g.us-east-1.rds.amazonaws.com:5432/ebdb
[Sat Mar 19 20:19:53.419884 2016] [:error] [pid 1080] ...above should read:
[Sat Mar 19 20:19:53.419889 2016] [:error] [pid 1080] ... postgresql://user:password#aa12jlddfw2awrj.cc6p9990ojvcx3g.us-east-1.rds.amazonaws.com:5432/ebdb
[Sat Mar 19 20:19:53.419893 2016] [:error] [pid 1080] ..............................................
[Sat Mar 19 20:19:53.419897 2016] [:error] [pid 1080] ...attempting engine = create_engine(URL(**settings.DATABASE))...
[Sat Mar 19 20:19:53.427168 2016] [:error] [pid 1080] ...................................................
[Sat Mar 19 20:19:53.427189 2016] [:error] [pid 1080] ...Failed to create engine in database_setup.py....
[Sat Mar 19 20:19:53.427193 2016] [:error] [pid 1080] ...................................................
[Sat Mar 19 20:19:53.427200 2016] [:error] [pid 1080] .................................................
[Sat Mar 19 20:19:53.427203 2016] [:error] [pid 1080] ...Failed to create session in application.py....
[Sat Mar 19 20:19:53.427206 2016] [:error] [pid 1080] .................................................
Here is the url for the running app:
http://keirseysorterapp.9yk6hymk2z.us-east-1.elasticbeanstalk.com/testApp
I was never able to get this to work. I ended up following this tutorial:
https://medium.com/#rodkey/deploying-a-flask-application-on-aws-a72daba6bb80#.t2lbbv5q3
The tutorial uses the Flask-SQLAlchemy module instead of importing Flask and SQLAlchemy separately. Once I used this method I had no problems. Good luck!

Why does page hang/timeout with apache2, mod_wsgi, django, in virtual environment and under non-privileged user

When I go to 52.1.65.249, the page hangs or times out. I have a django project located under a non-root user at /home/usrbkto/bkto/projbkto.
I have the same problem on two servers running ubuntu 14.04 and python 2.7.8 and ubuntu 15.04 and python 2.7.9. I believe the mod_wsgi on PyPi was compiled using python 2.7.8, so for the server running python 2.7.9 I downloaded from Github and compiled using the version of python on my server. Everything was working fine until I updated my packages all at once, so I'm not sure which package update broke things. I suspect that it has to do with the fact that I'm not using the new version of mod_wsgi correctly, but I'm not sure and I want to keep my Django project under a non-root user without access to Apache files.
My custom conf file at /etc/apache2/sites-available/bkto.conf is:
WSGIScriptAlias / /home/usrbkto/bkto/projbkto/projbkto/wsgi.py
WSGIPythonHome /home/usrbkto/vent
WSGIPythonPath /home/usrbkto/bkto/projbkto
LogLevel info
<Directory /home/usrbkto/bkto/projbkto/projbkto>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
Alias /media/ /home/usrbkto/bkto/projbkto/media/
Alias /static/ /home/usrbkto/bkto/projbkto/static/
<Directory /home/usrbkto/bkto/projbkto/static>
Require all granted
</Directory>
<Directory /home/usrbkto/bkto/projbkto/media>
Require all granted
</Directory>
The apache error.log is:
[Mon Jun 01 05:14:41.082545 2015] [mpm_event:notice] [pid 32630:tid 140666831587200] AH00489: Apache/2.4.10 (Ubuntu) mod_wsgi/4.4.12 Python/2.7.9 configured -- resuming normal operations
[Mon Jun 01 05:14:41.082692 2015] [mpm_event:info] [pid 32630:tid 140666831587200] AH00490: Server built: Mar 9 2015 11:53:48
[Mon Jun 01 05:14:41.082713 2015] [core:notice] [pid 32630:tid 140666831587200] AH00094: Command line: '/usr/sbin/apache2'
[Mon Jun 01 05:14:41.083297 2015] [wsgi:info] [pid 32634:tid 140666831587200] mod_wsgi (pid=32634): Python home /home/usrbkto/venv.
[Mon Jun 01 05:14:41.083401 2015] [wsgi:info] [pid 32634:tid 140666831587200] mod_wsgi (pid=32634): Initializing Python.
[Mon Jun 01 05:14:41.089325 2015] [wsgi:info] [pid 32632:tid 140666831587200] mod_wsgi (pid=32632): Python home /home/usrbkto/venv.
[Mon Jun 01 05:14:41.089442 2015] [wsgi:info] [pid 32632:tid 140666831587200] mod_wsgi (pid=32632): Initializing Python.
[Mon Jun 01 05:14:41.181394 2015] [wsgi:info] [pid 32634:tid 140666831587200] mod_wsgi (pid=32634): Attach interpreter ''.
[Mon Jun 01 05:14:41.181479 2015] [wsgi:info] [pid 32634:tid 140666831587200] mod_wsgi (pid=32634): Adding '/home/usrbkto/bkto/projbkto' to path.
[Mon Jun 01 05:14:41.182781 2015] [wsgi:info] [pid 32634:tid 140666831587200] mod_wsgi (pid=32634): Imported 'mod_wsgi'.
[Mon Jun 01 05:14:41.186652 2015] [wsgi:info] [pid 32632:tid 140666831587200] mod_wsgi (pid=32632): Attach interpreter ''.
[Mon Jun 01 05:14:41.186718 2015] [wsgi:info] [pid 32632:tid 140666831587200] mod_wsgi (pid=32632): Adding '/home/usrbkto/bkto/projbkto' to path.
[Mon Jun 01 05:14:41.212429 2015] [wsgi:info] [pid 32632:tid 140666831587200] mod_wsgi (pid=32632): Imported 'mod_wsgi'.
[Mon Jun 01 05:14:47.101220 2015] [wsgi:info] [pid 32634:tid 140666698360576] mod_wsgi (pid=32634): Create interpreter 'ip-172-31-4-180.ec2.internal|'.
[Mon Jun 01 05:14:47.102574 2015] [wsgi:info] [pid 32634:tid 140666698360576] mod_wsgi (pid=32634): Adding '/home/usrbkto/bkto/projbkto' to path.
[Mon Jun 01 05:14:47.104087 2015] [wsgi:info] [pid 32634:tid 140666698360576] [client 64.94.31.206:47918] mod_wsgi (pid=32634, process='', application='ip-172-31-4-180.ec2.internal|'): Loading WSGI script '/home/usrbkto/bkto/projbkto/projbkto/wsgi.py'.
[Mon Jun 01 05:16:46.847615 2015] [wsgi:info] [pid 32632:tid 140666612999936] mod_wsgi (pid=32632): Create interpreter 'ip-172-31-4-180.ec2.internal|'.
[Mon Jun 01 05:16:46.848995 2015] [wsgi:info] [pid 32632:tid 140666612999936] mod_wsgi (pid=32632): Adding '/home/usrbkto/bkto/projbkto' to path.
[Mon Jun 01 05:16:46.850506 2015] [wsgi:info] [pid 32632:tid 140666612999936] [client 166.137.244.128:61084] mod_wsgi (pid=32632, process='', application='ip-172-31-4-180.ec2.internal|'): Loading WSGI script '/home/usrbkto/bkto/projbkto/projbkto/wsgi.py'.
The wsgi.py file at /home/usrbkto/bkto/projbkto/projbkto/wsgi.py is:
"""
WSGI config for projbkto project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/1.7/howto/deployment/wsgi/
"""
import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "projbkto.settings")
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
The mod_wsgi versions of PyPi are source code and not binaries. To say the mod_wsgi on PyPi is compiled with a certain Python version doesn't make any sense as they are compiled on your own system using whatever Python version you have.
Anyway, read this and try the remedy given:
http://code.google.com/p/modwsgi/wiki/ApplicationIssues#Python_Simplified_GIL_State_API
This is the usual fix for lock ups caused by Python C extensions which aren't coded properly to work in sub interpreters.
Also stop using embedded mode and use daemon mode instead:
http://blog.dscpl.com.au/2012/10/why-are-you-using-embedded-mode-of.html
If these don't help, indicate whether it is easily reproducible or random.

Django stops working with RuntimeError: populate() isn't reentrant

I've been developing a Django web application deployed on an Apache server with WSGI, and everything has been going smoothly. Today, I made some minor changes to my app's admin.py in an attempt to customize the build-in Django Admin interface, and initially made a syntax error (an unclosed parenthesis). This meant that when I touched wsgi.py and loaded the code (I have WSGI running in daemon mode on my virtual host), my website was replaced with an Internal Server Error because WSGI stopped when it hit the syntax error.
So I fixed the syntax error, checked that I didn't have any more with manage.py check, and touched wsgi.py to redeploy. But my website still displays an Internal Server Error! Checking the Apache logs, this is what I see:
[Sun Nov 23 13:52:46 2014] [info] mod_wsgi (pid=19093): Create interpreter 'quotes.cs.cornell.edu|'.
[Sun Nov 23 13:52:46 2014] [info] mod_wsgi (pid=19093): Adding '/extra/www/html/quotes/quotes_django' to path.
[Sun Nov 23 13:52:46 2014] [info] mod_wsgi (pid=19093): Adding '/opt/rh/python27/root/usr/lib64/python2.7/site-
packages/' to path.
[Sun Nov 23 13:52:46 2014] [info] [client 128.84.33.19] mod_wsgi (pid=19093, process='quotes.cs.cornell.edu',
application='quotes.cs.cornell.edu|'): Loading WSGI script '/extra/www/html/quotes/quotes_django/quotes_django/
wsgi.py'.
[Sun Nov 23 13:52:46 2014] [error] [client 128.84.33.19] mod_wsgi (pid=19093): Target WSGI script '/extra/www/html/
quotes/quotes_django/quotes_django/wsgi.py' cannot be loaded as Python module.
[Sun Nov 23 13:52:46 2014] [error] [client 128.84.33.19] mod_wsgi (pid=19093): Exception occurred processing WSGI
script '/extra/www/html/quotes/quotes_django/quotes_django/wsgi.py'.
[Sun Nov 23 13:52:46 2014] [error] [client 128.84.33.19] Traceback (most recent call last):
[Sun Nov 23 13:52:46 2014] [error] [client 128.84.33.19] File "/extra/www/html/quotes/quotes_django/
quotes_django/wsgi.py", line 14, in <module>
[Sun Nov 23 13:52:46 2014] [error] [client 128.84.33.19] application = get_wsgi_application()
[Sun Nov 23 13:52:46 2014] [error] [client 128.84.33.19] File "/opt/rh/python27/root/usr/lib64/python2.7/site-
packages/django/core/wsgi.py", line 14, in get_wsgi_application
[Sun Nov 23 13:52:46 2014] [error] [client 128.84.33.19] django.setup()
[Sun Nov 23 13:52:46 2014] [error] [client 128.84.33.19] File "/opt/rh/python27/root/usr/lib64/python2.7/site-
packages/django/__init__.py", line 21, in setup
[Sun Nov 23 13:52:46 2014] [error] [client 128.84.33.19] apps.populate(settings.INSTALLED_APPS)
[Sun Nov 23 13:52:46 2014] [error] [client 128.84.33.19] File "/opt/rh/python27/root/usr/lib64/python2.7/site-
packages/django/apps/registry.py", line 115, in populate
[Sun Nov 23 13:52:46 2014] [error] [client 128.84.33.19] app_config.ready()
[Sun Nov 23 13:52:46 2014] [error] [client 128.84.33.19] File "/opt/rh/python27/root/usr/lib64/python2.7/site-
packages/django/contrib/admin/apps.py", line 22, in ready
[Sun Nov 23 13:52:46 2014] [error] [client 128.84.33.19] self.module.autodiscover()
[Sun Nov 23 13:52:46 2014] [error] [client 128.84.33.19] File "/opt/rh/python27/root/usr/lib64/python2.7/site-
packages/django/contrib/admin/__init__.py", line 23, in autodiscover
[Sun Nov 23 13:52:46 2014] [error] [client 128.84.33.19] autodiscover_modules('admin', register_to=site)
[Sun Nov 23 13:52:46 2014] [error] [client 128.84.33.19] File "/opt/rh/python27/root/usr/lib64/python2.7/site-
packages/django/utils/module_loading.py", line 74, in autodiscover_modules
[Sun Nov 23 13:52:46 2014] [error] [client 128.84.33.19] import_module('%s.%s' % (app_config.name,
module_to_search))
[Sun Nov 23 13:52:46 2014] [error] [client 128.84.33.19] File "/usr/lib64/python2.7/importlib/__init__.py", line
37, in import_module
[Sun Nov 23 13:52:46 2014] [error] [client 128.84.33.19] __import__(name)
[Sun Nov 23 13:52:46 2014] [error] [client 128.84.33.19] File "/extra/www/html/quotes/quotes_django/quotespage/
admin.py", line 25
[Sun Nov 23 13:52:46 2014] [error] [client 128.84.33.19] approve_quotes.short_description = "Approve selected
quotes"
[Sun Nov 23 13:52:46 2014] [error] [client 128.84.33.19] ^
[Sun Nov 23 13:52:46 2014] [error] [client 128.84.33.19] SyntaxError: invalid syntax
[Sun Nov 23 13:53:36 2014] [info] [client 128.84.33.19] mod_wsgi (pid=19093, process='quotes.cs.cornell.edu',
application='quotes.cs.cornell.edu|'): Loading WSGI script '/extra/www/html/quotes/quotes_django/quotes_django/
wsgi.py'.
[Sun Nov 23 13:53:36 2014] [error] [client 128.84.33.19] mod_wsgi (pid=19093): Target WSGI script '/extra/www/html/
quotes/quotes_django/quotes_django/wsgi.py' cannot be loaded as Python module.
[Sun Nov 23 13:53:36 2014] [error] [client 128.84.33.19] mod_wsgi (pid=19093): Exception occurred processing WSGI
script '/extra/www/html/quotes/quotes_django/quotes_django/wsgi.py'.
[Sun Nov 23 13:53:36 2014] [error] [client 128.84.33.19] Traceback (most recent call last):
[Sun Nov 23 13:53:36 2014] [error] [client 128.84.33.19] File "/extra/www/html/quotes/quotes_django/
quotes_django/wsgi.py", line 14, in <module>
[Sun Nov 23 13:53:36 2014] [error] [client 128.84.33.19] application = get_wsgi_application()
[Sun Nov 23 13:53:36 2014] [error] [client 128.84.33.19] File "/opt/rh/python27/root/usr/lib64/python2.7/site-
packages/django/core/wsgi.py", line 14, in get_wsgi_application
[Sun Nov 23 13:53:36 2014] [error] [client 128.84.33.19] django.setup()
[Sun Nov 23 13:53:36 2014] [error] [client 128.84.33.19] File "/opt/rh/python27/root/usr/lib64/python2.7/site-
packages/django/__init__.py", line 21, in setup
[Sun Nov 23 13:53:36 2014] [error] [client 128.84.33.19] apps.populate(settings.INSTALLED_APPS)
[Sun Nov 23 13:53:36 2014] [error] [client 128.84.33.19] File "/opt/rh/python27/root/usr/lib64/python2.7/site-
packages/django/apps/registry.py", line 78, in populate
[Sun Nov 23 13:53:36 2014] [error] [client 128.84.33.19] raise RuntimeError("populate() isn't reentrant")
[Sun Nov 23 13:53:36 2014] [error] [client 128.84.33.19] RuntimeError: populate() isn't reentrant
The first series of errors shows WSGI failing due to the syntax error in my admin.py. However, the second series of errors seems to show an error internal to Django:
RuntimeError: populate() isn't reentrant
thrown from the populate method of registry.py.
Googling this error message returns surprisingly little information, none of it from Django documentation. Apparently, it can sometimes happen if you name an app twice in your settings.py, but I'm not doing that. More importantly, I haven't changed settings.py since the point where the website was working fine -- the only thing I changed was admin.py.
I tried reverting all the changes I made, so all my Python code is back in the state it was when the website was working -- and I still get the populate() isn't reentrant error when I try to make WSGI reload the code!
I've also tried commenting-out different apps in the INSTALLED_APPS section of settings.py, and even with only 'django.contrib.staticfiles' enabled the error still happens. Weirdly, I still get the error even if I comment out all the apps -- Django throws the error even when it isn't loading any apps!
Does anyone know what's going on here? Or any better way for me to debug this error, since the traceback in the Apache log is pretty unhelpful?
Notes: I'm using Django 1.7, Apache 2.2, and Python 2.7.
This is caused by a bug in your Django settings somewhere. Unfortunately, Django's hiding the bug behind this generic and un-useful error message.
To reveal the true problem, open django/apps/registry.py and around line 80, replace:
raise RuntimeError("populate() isn't reentrant")
with:
self.app_configs = {}
This will allow Django to continue loading, and reveal the actual error.
I've encountered this error for several different causes. Once was because I had a bad import in one of my app's admin.py.
Update from the Future
Since this question has continued to receive attention years after I originally asked it, I thought I should update my answer to better help future readers solve their problems.
It turns out there are (at least) two different reasons you could be getting the "populate() isn't reentrant" error, and thus two different approaches to solving the problem:
There is an error in your Python code or your Django settings that makes your app fail to initialize correctly. As #Cerin's answer points out, Django hides the real problem behind the unhelpful "populate isn't reentrant" message. To fix this and reveal the actual error, follow #Cerin's advice and edit django/apps/registry.py to make Django stop throwing the RuntimeError.
There was at one point an error in your Python code, but you have fixed it, and Django still keeps failing with this message because WSGI won't reload your fixed code. This is a WSGI problem, not a Django problem. One way to fix it is to temporarily edit wsgi.py so that its application function kills the WSGI process (forcing it to restart), as I described in my original answer; another is to set the startup-timeout option of mod_wsgi so that WSGI will restart itself, as #Graham Dumpleton described in the comments. Restarting the entire Apache server also fixes this problem, because it will incidentally restart WSGI, although that's a bit heavy-handed and not always possible if you're not an admin on the webserver.
Original answer below:
My server's administrator restarted Apache, and that magically fixed this problem. The exact same Python files loaded without causing populate() isn't reentrant. I even tried loading another file with a syntax error, then fixing it, and the server was able to load the new file and run correctly with no problems.
I still don't know what was going wrong, but I'm marking this as answered since the problem is gone. (Well, I'll mark it as answered as soon as StackOverflow allows me to accept my own answer.)
Update: After continuing to get this error when I accidentally upload Python with syntax errors, I figured out a workaround that's easier than restarting Apache. When WSGI starts throwing the populate() isn't reentrant error, I replace my Django project's wsgi.py with this simple function:
def application(environ, start_response):
if environ['mod_wsgi.process_group'] != '':
import signal
os.kill(os.getpid(), signal.SIGINT)
return ["killed"]
Then I reload my website, and the WSGI daemon process restarts (which I can tell by looking at the Apache log, even though the website still displays the same 500 error).
If I then change wsgi.py back to normal and reload again, WSGI successfully picks up my code without throwing populate() isn't reentrant (assuming I have no syntax errors this time). So the entirety of Apache doesn't need to restart, just the WSGI process, and I can do that without root privileges.
I know this is an old answer but I will contribute with my solution:
As a way to diagnose the source of the problem run manage.py checkand see if you find anything there
In my case an outdated requirement was the issue and django was failing to import a submodule
Make sure that your requirements are up to date
It's not a response but a reflexion.
When you upgrade to django 1.7 and you have a 500 error and reload your page, Apache says "populate() isn't reentrant".
I think it's when you load your page, Apache load all the modules you need for your app and when the error is handle it doesn't unload module. So, when you reload your page, apache load again theses modules but it's already loaded. So, apache says "populate() isn't reentrant".
I've two actions to correct this : Restart apache, or correct the error that handle the first 5OO error.
Try restarting apache with:
sudo service httpd restart
I hope it will help you.
If you're getting this error when using Google App Engine check your logs for other errors which might be causing this. I was getting:
ImproperlyConfigured: Error loading either pysqlite2 or sqlite3 modules (tried in that order): No module named _sqlite3
You can't use SQLite with Google App Engine so commenting out the DATABASES section of settings.py stopped that error and the RuntimeError("populate() isn't reentrant") error as well.
You may be able to fix it without restarting Apache by touching a file (other than wsgi.py) that is early on in the loading process. For example, your settings file:
$ touch settings.py
I haven't properly solved this either, but more info in my question here: Code change monitoring malfunctioning with Django 1.7 on mod-wsgi
Apache stores the wsgi file in its cache.
Disable Apache caching of python files
So first delete the wsgi file and restart your acpache and then add wsgi file again and restart the apache.
This error also generated if inconsistence use of space and tab in the code.
I just faced the same problem so I started looking around.
Now I've got it working, so I thought I should share it with you guys!
All I did was do chown user:group /to/path -R and chmod 770 /to/path -R all over again and it worked.
This looks like a nice collection of valid responses for the same Apache mod-wsgi error, each guy posting the one that works for him/her, so here is mine:
Do not forget to update your project requirements after deploying :)
I experienced this same problem, and the source of the error for me was just a syntax error in a file I was working with. After fixing the typo, the populate() is not reentrant error disappeared.
If you are running django from a wsgi script, you might be able to identify the typo by just running the wsgi script from the command line. For example:
cd /usr/local/www/wsgi-scripts/
python djangolauncher.wsgi
If you tested your syntax in your dev environment and everything is ok, then the problem is here
WSGIDaemonProcess celeryEnv python-path=/var/www/celeryEnv/lib/python3.6/site-packages user=apache group=apache python-home=/var/www/celeryEnv
apache only look at
python-path=/var/www/celeryEnv/lib/python3.6/site-packages
so any modules in lib64 will not be recognized in apache
I found a workaround by coping all modules in /var/www/celeryEnv/lib64
to /var/www/celeryEnv/lib
now apache will work here's the line from my own servers
WSGIDaemonProcess domain.com python-path=/home/user/app/env/lib/python3.6/site-packages:/home/user/app
Note: there's beneficial information already here, but I put this answer because My servers are mostly Centos-7 which are working as it should with my answer !!
Setup: Ubuntu 14.04, Django 1.10, Python 3.5 (in virtualenv).
I tried many of these solutions without luck, but then I noticed that the Apache error log contains two different errors in my case. One that happens when someone tries to visit a page, another that happens at start up. I missed the startup one because I usually tried to refresh the page a couple of times and thus only saw the on visit error repeated a few times.
I then searched for solutions to the startup error instead and the solution to this question worked for me. Briefly, it involves updating the mod_wsgi package in a roundabout way.
I had been receiving warnings for months about the mismatch in mod_wsgi versions, but suddenly it resulted in Apache error 500's. Doesn't make any sense to me.
My guess is that this RuntimeError: populate() isn't reentrant error is usually a sign that one should look for a startup error, which indicates the real problem.
on visit
[Sat Oct 15 03:38:08.900966 2016] [:error] [pid 28272] [remote 95.166.81.114:39651] mod_wsgi (pid=28272): Target WSGI script '/django/GP/GP/wsgi.py' cannot be loaded as Python module.
[Sat Oct 15 03:38:08.901409 2016] [:error] [pid 28272] [remote 95.166.81.114:39651] mod_wsgi (pid=28272): Exception occurred processing WSGI script '/django/GP/GP/wsgi.py'.
[Sat Oct 15 03:38:08.901662 2016] [:error] [pid 28272] [remote 95.166.81.114:39651] Traceback (most recent call last):
[Sat Oct 15 03:38:08.902184 2016] [:error] [pid 28272] [remote 95.166.81.114:39651] File "/django/GP/GP/wsgi.py", line 16, in <module>
[Sat Oct 15 03:38:08.902217 2016] [:error] [pid 28272] [remote 95.166.81.114:39651] application = get_wsgi_application()
[Sat Oct 15 03:38:08.902501 2016] [:error] [pid 28272] [remote 95.166.81.114:39651] File "/django/env/lib/python3.5/site-packages/django/core/wsgi.py", line 13, in get_wsgi_application
[Sat Oct 15 03:38:08.902529 2016] [:error] [pid 28272] [remote 95.166.81.114:39651] django.setup(set_prefix=False)
[Sat Oct 15 03:38:08.902726 2016] [:error] [pid 28272] [remote 95.166.81.114:39651] File "/django/env/lib/python3.5/site-packages/django/__init__.py", line 27, in setup
[Sat Oct 15 03:38:08.902755 2016] [:error] [pid 28272] [remote 95.166.81.114:39651] apps.populate(settings.INSTALLED_APPS)
[Sat Oct 15 03:38:08.902924 2016] [:error] [pid 28272] [remote 95.166.81.114:39651] File "/django/env/lib/python3.5/site-packages/django/apps/registry.py", line 78, in populate
[Sat Oct 15 03:38:08.902953 2016] [:error] [pid 28272] [remote 95.166.81.114:39651] raise RuntimeError("populate() isn't reentrant")
[Sat Oct 15 03:38:08.903111 2016] [:error] [pid 28272] [remote 95.166.81.114:39651] RuntimeError: populate() isn't reentrant
start up
[Sat Oct 15 03:38:08.900966 2016] [:error] [pid 28272] [remote 95.166.81.114:39651] mod_wsgi (pid=28272): Target WSGI script '/django/GP/GP/wsgi.py' cannot be loaded as Python module.
[Sat Oct 15 03:38:08.901409 2016] [:error] [pid 28272] [remote 95.166.81.114:39651] mod_wsgi (pid=28272): Exception occurred processing WSGI script '/django/GP/GP/wsgi.py'.
[Sat Oct 15 03:38:08.901662 2016] [:error] [pid 28272] [remote 95.166.81.114:39651] Traceback (most recent call last):
[Sat Oct 15 03:38:08.902184 2016] [:error] [pid 28272] [remote 95.166.81.114:39651] File "/django/GP/GP/wsgi.py", line 16, in <module>
[Sat Oct 15 03:38:08.902217 2016] [:error] [pid 28272] [remote 95.166.81.114:39651] application = get_wsgi_application()
[Sat Oct 15 03:38:08.902501 2016] [:error] [pid 28272] [remote 95.166.81.114:39651] File "/django/env/lib/python3.5/site-packages/django/core/wsgi.py", line 13, in get_wsgi_application
[Sat Oct 15 03:38:08.902529 2016] [:error] [pid 28272] [remote 95.166.81.114:39651] django.setup(set_prefix=False)
[Sat Oct 15 03:38:08.902726 2016] [:error] [pid 28272] [remote 95.166.81.114:39651] File "/django/env/lib/python3.5/site-packages/django/__init__.py", line 27, in setup
[Sat Oct 15 03:38:08.902755 2016] [:error] [pid 28272] [remote 95.166.81.114:39651] apps.populate(settings.INSTALLED_APPS)
[Sat Oct 15 03:38:08.902924 2016] [:error] [pid 28272] [remote 95.166.81.114:39651] File "/django/env/lib/python3.5/site-packages/django/apps/registry.py", line 78, in populate
[Sat Oct 15 03:38:08.902953 2016] [:error] [pid 28272] [remote 95.166.81.114:39651] raise RuntimeError("populate() isn't reentrant")
[Sat Oct 15 03:38:08.903111 2016] [:error] [pid 28272] [remote 95.166.81.114:39651] RuntimeError: populate() isn't reentrant
[Sat Oct 15 03:38:43.291502 2016] [:error] [pid 28272] Exception ignored in: <module 'threading' from '/usr/lib/python3.4/threading.py'>
[Sat Oct 15 03:38:43.291579 2016] [:error] [pid 28272] Traceback (most recent call last):
[Sat Oct 15 03:38:43.291604 2016] [:error] [pid 28272] File "/usr/lib/python3.4/threading.py", line 1288, in _shutdown
[Sat Oct 15 03:38:43.292356 2016] [:error] [pid 28272] assert tlock is not None
[Sat Oct 15 03:38:43.292377 2016] [:error] [pid 28272] AssertionError:
[Fri Oct 14 23:38:43.412942 2016] [:error] [pid 28299] Exception ignored in: <module 'threading' from '/usr/lib/python3.4/threading.py'>
[Fri Oct 14 23:38:43.413044 2016] [:error] [pid 28299] Traceback (most recent call last):
[Fri Oct 14 23:38:43.413076 2016] [:error] [pid 28299] File "/usr/lib/python3.4/threading.py", line 1288, in _shutdown
[Fri Oct 14 23:38:43.425037 2016] [:error] [pid 28275] Exception ignored in: <module 'threading' from '/usr/lib/python3.4/threading.py'>
[Fri Oct 14 23:38:43.425125 2016] [:error] [pid 28275] Traceback (most recent call last):
[Fri Oct 14 23:38:43.425157 2016] [:error] [pid 28275] File "/usr/lib/python3.4/threading.py", line 1288, in _shutdown
[Fri Oct 14 23:38:43.427625 2016] [:error] [pid 28274] Exception ignored in: <module 'threading' from '/usr/lib/python3.4/threading.py'>
[Fri Oct 14 23:38:43.427694 2016] [:error] [pid 28274] Traceback (most recent call last):
[Fri Oct 14 23:38:43.427722 2016] [:error] [pid 28274] File "/usr/lib/python3.4/threading.py", line 1288, in _shutdown
[Fri Oct 14 23:38:43.432020 2016] [:error] [pid 28273] Exception ignored in: <module 'threading' from '/usr/lib/python3.4/threading.py'>
[Fri Oct 14 23:38:43.432078 2016] [:error] [pid 28273] Traceback (most recent call last):
[Fri Oct 14 23:38:43.432105 2016] [:error] [pid 28273] File "/usr/lib/python3.4/threading.py", line 1288, in _shutdown
[Fri Oct 14 23:38:43.438577 2016] [:error] [pid 28299] assert tlock is not None
[Fri Oct 14 23:38:43.438654 2016] [:error] [pid 28299] AssertionError:
[Fri Oct 14 23:38:43.442174 2016] [:error] [pid 28274] assert tlock is not None
[Fri Oct 14 23:38:43.442226 2016] [:error] [pid 28274] AssertionError:
[Fri Oct 14 23:38:43.447227 2016] [:error] [pid 28276] Exception ignored in: <module 'threading' from '/usr/lib/python3.4/threading.py'>
[Fri Oct 14 23:38:43.447294 2016] [:error] [pid 28276] Traceback (most recent call last):
[Fri Oct 14 23:38:43.447326 2016] [:error] [pid 28276] File "/usr/lib/python3.4/threading.py", line 1288, in _shutdown
[Fri Oct 14 23:38:43.448813 2016] [:error] [pid 28277] Exception ignored in: <module 'threading' from '/usr/lib/python3.4/threading.py'>
[Fri Oct 14 23:38:43.448876 2016] [:error] [pid 28277] Traceback (most recent call last):
[Fri Oct 14 23:38:43.448903 2016] [:error] [pid 28277] File "/usr/lib/python3.4/threading.py", line 1288, in _shutdown
[Fri Oct 14 23:38:43.450188 2016] [:error] [pid 28273] assert tlock is not None
[Fri Oct 14 23:38:43.450231 2016] [:error] [pid 28273] AssertionError:
[Fri Oct 14 23:38:43.456680 2016] [:error] [pid 28275] assert tlock is not None
[Fri Oct 14 23:38:43.456737 2016] [:error] [pid 28275] AssertionError:
[Fri Oct 14 23:38:43.461761 2016] [:error] [pid 28277] assert tlock is not None
[Fri Oct 14 23:38:43.461826 2016] [:error] [pid 28277] AssertionError:
[Fri Oct 14 23:38:43.466165 2016] [:error] [pid 28276] assert tlock is not None
[Fri Oct 14 23:38:43.466219 2016] [:error] [pid 28276] AssertionError:
[Fri Oct 14 23:38:43.658971 2016] [mpm_prefork:notice] [pid 28268] AH00169: caught SIGTERM, shutting down
[Sat Oct 15 03:38:43.691909 2016] [:error] [pid 28272] Exception ignored in: <module 'threading' from '/usr/lib/python3.4/threading.py'>
[Sat Oct 15 03:38:43.691968 2016] [:error] [pid 28272] Traceback (most recent call last):
[Sat Oct 15 03:38:43.691996 2016] [:error] [pid 28272] File "/usr/lib/python3.4/threading.py", line 1288, in _shutdown
[Sat Oct 15 03:38:43.693126 2016] [:error] [pid 28272] assert tlock is not None
[Sat Oct 15 03:38:43.693159 2016] [:error] [pid 28272] AssertionError:
[Fri Oct 14 23:38:44.490316 2016] [:warn] [pid 28349] mod_wsgi: Compiled for Python/3.4.0.
[Fri Oct 14 23:38:44.490407 2016] [:warn] [pid 28349] mod_wsgi: Runtime using Python/3.4.3.
[Fri Oct 14 23:38:44.505672 2016] [mpm_prefork:notice] [pid 28349] AH00163: Apache/2.4.7 (Ubuntu) PHP/5.5.9-1ubuntu4.19 mod_wsgi/3.4 Python/3.4.3 configured -- resuming normal operations
[Fri Oct 14 23:38:44.505764 2016] [core:notice] [pid 28349] AH00094: Command line: '/usr/sbin/apache2'
I know it has been a while since this question was asked, but I just ran into this issue due to a problem I haven't seen discussed here. I was getting the RuntimeError: populate() isn't reentrant error due to SELinux on CentOS 7. I had Django served out of a home directory, and I simply had to enable the SELinux boolean that allowed reading home directories, as the populate() error was due to a permissions issue. The solution for me was setsebool -P httpd_read_user_content 1. I hope this helps someone having this issue.
In my case the error occured because a required pip-package was missing.
So I did a pip install -r requirements.txt, restarted apache and things worked again.
In my case, I had a circular import, which cause an error that break the populate method.
The multitude of answers makes it clear; this is a generic error that can have multiple root causes, typically related to loading Apache/WSGI.
All of these answers on this page should function as a kind of checklist, and in that vein I want to add the root cause of my instance of this error: failure to add an 'import os' to your settings.py file.
Specifically, we had a developer on our team who intended to remove an unneeded package, and instead removed 'import os' from the top of the production settings.py file. After an apache restart, our application wouldn't restart and we received the dreaded 'RuntimeError: populate() isn't reentrant' error.
A quick 'python manage.py check' did not reveal the issue, but a 'python settings.py' did; the os package was not loaded.
If you have this error, focus your search on checking your settings.py file(s) and also your WSGI file.
RuntimeError: populate() isn't reentrant
Can be anything, that is why there are so many different answers for this question.
The trick is to look at the error message just before the RuntimeError. In your case there seems to be a syntax error in the file /extra/www/htmlquotes/quotes_django/quotespage/admin.py on line 15, see:
Sun Nov 23 13:52:46 2014] [error] [client 128.84.33.19] File "/extra/www/htmlquotes/quotes_django/quotespage/admin.py", line 25
[Sun Nov 23 13:52:46 2014] [error] [client 128.84.33.19] pprove_quotes.short_description = "Approve selected quotes"
[Sun Nov 23 13:52:46 2014] [error] [client 128.84.33.19] ^
[Sun Nov 23 13:52:46 2014] [error] [client 128.84.33.19] SyntaxError: invalid syntax
I had a recursive django.setup(), eg I tried to write a django.setup() inside a an app/models.py, in the stack trace django tried to point this out near:
... "site-packages/django/apps/config.py", line 211, in import_models
self.models_module = import_module(models_module_name)
...
... ./myproject/myapp/models.py ...
so yeah, be sure not to try to setup django while django is being setup...
Note on AWS Elastic Beanstalk: The default settings.py that is written by Django-admin includes a reference to a local sqlite database as the data source. This will likely work on your local OS, but not on AWS EB, and will give the populate() isn't reentrant runtime error. To test for this, simply comment out the DATABASES={<...>} statement in settings.py, deploy, and re-open the application.
For me the error was a missing mysqlclient package in the requirements.txt file.
First I installed the mysqlclient package with:
pip install mysqlclient
then I updated the requirements.txt file with:
pip freeze > requirements.txt
and this solved my problem.
I had this problem and couldn't find any answer why until I backtracked my commits. Apparently I had added an accidental import, because of auto-completion, that screwed up the setup.
# found in models.py
from msilib.schema import SelfReg
In apache error log:
RuntimeError("populate() isn't reentrant")
It worked fine in my windows dev environment but failed on the ubuntu/apache server.
I was going into this same error after having change the order of this setting :
MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.security.SecurityMiddleware',
)
putting it back on the order here before and restarting apache fixed the issue.
In my case, I had a custom renderer class for Django Rest Framework, for some purpose I had to override the renderer class's method "get_context" (full disclosure : to make django toolbar give correct SQL query count)
I removed that class and redeployed. It Worked.
Removing the virtualenv directory, recreating the virtualenv, then reinstalling all the requirements fixed it for me.
I hesitate to add this as an answer since it's really just a description of a related case. However, it didn't seem legible as a comment.
I ran into this error when creating a function that could access the Django database without the server running. Mostly, this was being used for inserting test data entries.
My project had the following in its project/apps/app_one/functions.py file:
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "Project.settings")
import django
django.setup()
This allows access to the Django database through Python scripts without a server running. See here for more info on this approach: https://stackoverflow.com/a/26875729/4573162
I was also keeping basic app functions in this file that didn't require database access and were to be used while a server was running. For example, in my app_one.models.py I might have the following usage of a functions.arg_format function, imported from the app_name/functions.py file:
def save(self, *args, **kwargs):
self.some_arg = functions.arg_format(self.some_arg)
super().save(*args, **kwargs)
What this amounts to is that my application, while running, was trying to again run the Django setup().
I dont' know how related this is but it threw the same RuntimeError: populate() isn't reentrant error until I created a separate file for all the database-accessing functions. After the additional setup() import was sidestepped, migrations were able to be completed as expected.
Adding my reason to the list.
For me it was because I had a django service named with the same directory as a process directory. Renaming the process/dir fixed the issue.
Restarting the Apache server for me solved the problem. You can do that by using the command
$ sudo service apache2 restart
I had this same issue, what worked for me was commenting out the default database settings in / settings.py . I also read that later versions of django are not compatible with ebs
In apps.py, i have set different name from my app name.

What is the issue with my wamp server

Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request. Please contact the server administrator at admin#example.com to inform them of the time this error occurred, and the actions you performed just before this error.
More infortion.
After i went through the log file i found this but i dont know how to debug it
[Wed Sep 24 12:29:50.808777 2014] [mpm_winnt:notice] [pid 7716:tid 304] AH00364: Child: All worker threads have exited.
[Wed Sep 24 12:29:53.569982 2014] [mpm_winnt:notice] [pid 6836:tid 388] AH00430: Parent: Child process 7716 exited successfully.
[Wed Sep 24 12:38:59.563516 2014] [mpm_winnt:notice] [pid 4612:tid 388] AH00455: Apache/2.4.9 (Win64) PHP/5.5.12 configured -- resuming normal operations
[Wed Sep 24 12:38:59.598518 2014] [mpm_winnt:notice] [pid 4612:tid 388] AH00456: Apache Lounge VC11 Server built: Mar 16 2014 12:42:59
[Wed Sep 24 12:38:59.598518 2014] [core:notice] [pid 4612:tid 388] AH00094: Command line: 'c:\\wamp\\bin\\apache\\apache2.4.9\\bin\\httpd.exe -d C:/wamp/bin/apache/apache2.4.9'
[Wed Sep 24 12:38:59.600518 2014] [mpm_winnt:notice] [pid 4612:tid 388] AH00418: Parent: Created child process 5232
[Wed Sep 24 12:39:00.554573 2014] [mpm_winnt:notice] [pid 5232:tid 304] AH00354: Child: Starting 64 worker threads.
[Wed Sep 24 20:59:56.118653 2014] [mpm_winnt:notice] [pid 4612:tid 388] AH00422: Parent: Received shutdown signal -- Shutting down the server.
[Wed Sep 24 20:59:58.571793 2014] [mpm_winnt:notice] [pid 5232:tid 304] AH00364: Child: All worker threads have exited.
[Wed Sep 24 21:00:23.437495 2014] [mpm_winnt:notice] [pid 4612:tid 388] AH00430: Parent: Child process 5232 exited successfully.
[Thu Sep 25 08:41:53.157396 2014] [mpm_winnt:notice] [pid 1032:tid 392] AH00455: Apache/2.4.9 (Win64) PHP/5.5.12 configured -- resuming normal operations
[Thu Sep 25 08:41:53.166397 2014] [mpm_winnt:notice] [pid 1032:tid 392] AH00456: Apache Lounge VC11 Server built: Mar 16 2014 12:42:59
[Thu Sep 25 08:41:53.166397 2014] [core:notice] [pid 1032:tid 392] AH00094: Command line: 'c:\\wamp\\bin\\apache\\apache2.4.9\\bin\\httpd.exe -d C:/wamp/bin/apache/apache2.4.9'
[Thu Sep 25 08:41:53.168397 2014] [mpm_winnt:notice] [pid 1032:tid 392] AH00418: Parent: Created child process 6796
[Thu Sep 25 08:41:55.282518 2014] [mpm_winnt:notice] [pid 6796:tid 316] AH00354: Child: Starting 64 worker threads.
[Thu Sep 25 10:46:27.453901 2014] [core:error] [pid 6796:tid 836] [client 127.0.0.1:4242] AH00124: Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.
[Thu Sep 25 10:47:56.015967 2014] [core:error] [pid 6796:tid 844] [client 127.0.0.1:4282] AH00124: Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.
[Thu Sep 25 10:53:11.816030 2014] [core:error] [pid 6796:tid 832] [client 127.0.0.1:4443] AH00124: Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.
[Thu Sep 25 10:55:26.231718 2014] [core:error] [pid 6796:tid 852] [client 127.0.0.1:4476] AH00124: Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.
Request exceeded the limit of 10 internal redirects due to probable configuration error.
In combination with the the 500 (internal server) error message, it kind of sounds like you have a problem with the RedirectRule lines in your .htaccess file, that keep on redirecting the request in a loop.

"End of script output before headers: wsgi.py" when uploading a picture in Django from iOS device

For some reason, sometimes when my users are uploading a pictures, I keep getting a 500 error, which I can't reproduce on my own. The only thing I can see in my django/apache/wsgi logs is this:
[core:error] [pid 17191] End of script output before headers: wsgi.py
I have no idea where to start...
EDIT #1
I changed my LogLevel to Debug and I got the following:
[Tue Dec 17 14:11:46.600635 2013] [proxy:debug] [pid 29456] proxy_util.c(1734): AH00927: initializing worker proxy:reverse local
[Tue Dec 17 14:11:46.600709 2013] [proxy:debug] [pid 29456] proxy_util.c(1785): AH00931: initialized single connection worker in child 29456 for (*)
[Tue Dec 17 14:11:46.600788 2013] [:info] [pid 29456] mod_wsgi (pid=29456): Initializing Python.
[Tue Dec 17 14:11:46.608906 2013] [:info] [pid 29455] mod_wsgi (pid=29455): Starting process 'poka' with uid=48, gid=48 and threads=15.
[Tue Dec 17 14:11:46.609425 2013] [:info] [pid 29455] mod_wsgi (pid=29455): Initializing Python.
[Tue Dec 17 14:11:46.612573 2013] [proxy:debug] [pid 29457] proxy_util.c(1694): AH00925: initializing worker proxy:reverse shared
[Tue Dec 17 14:11:46.612627 2013] [proxy:debug] [pid 29457] proxy_util.c(1734): AH00927: initializing worker proxy:reverse local
[Tue Dec 17 14:11:46.612698 2013] [proxy:debug] [pid 29457] proxy_util.c(1785): AH00931: initialized single connection worker in child 29457 for (*)
[Tue Dec 17 14:11:46.612779 2013] [:info] [pid 29457] mod_wsgi (pid=29457): Initializing Python.
[Tue Dec 17 14:11:46.616459 2013] [proxy:debug] [pid 29458] proxy_util.c(1694): AH00925: initializing worker proxy:reverse shared
[Tue Dec 17 14:11:46.616511 2013] [proxy:debug] [pid 29458] proxy_util.c(1734): AH00927: initializing worker proxy:reverse local
[Tue Dec 17 14:11:46.616574 2013] [proxy:debug] [pid 29458] proxy_util.c(1785): AH00931: initialized single connection worker in child 29458 for (*)
[Tue Dec 17 14:11:46.616644 2013] [:info] [pid 29458] mod_wsgi (pid=29458): Initializing Python.
[Tue Dec 17 14:11:46.630974 2013] [proxy:debug] [pid 29459] proxy_util.c(1694): AH00925: initializing worker proxy:reverse shared
[Tue Dec 17 14:11:46.631046 2013] [proxy:debug] [pid 29459] proxy_util.c(1734): AH00927: initializing worker proxy:reverse local
[Tue Dec 17 14:11:46.631116 2013] [proxy:debug] [pid 29459] proxy_util.c(1785): AH00931: initialized single connection worker in child 29459 for (*)
[Tue Dec 17 14:11:46.631195 2013] [:info] [pid 29459] mod_wsgi (pid=29459): Initializing Python.
[Tue Dec 17 14:11:46.664817 2013] [mpm_prefork:notice] [pid 29453] AH00163: Apache/2.4.6 (Amazon) OpenSSL/1.0.1e-fips mod_wsgi/3.4 Python/2.7.5 configured -- resuming normal operations
[Tue Dec 17 14:11:46.664879 2013] [mpm_prefork:info] [pid 29453] AH00164: Server built: Sep 20 2013 18:01:06
[Tue Dec 17 14:11:46.664901 2013] [core:notice] [pid 29453] AH00094: Command line: '/usr/sbin/httpd'
[Tue Dec 17 14:11:46.664939 2013] [mpm_prefork:debug] [pid 29453] prefork.c(995): AH00165: Accept mutex: sysvsem (default: sysvsem)
[Tue Dec 17 14:11:46.668668 2013] [proxy:debug] [pid 29460] proxy_util.c(1694): AH00925: initializing worker proxy:reverse shared
[Tue Dec 17 14:11:46.668748 2013] [proxy:debug] [pid 29460] proxy_util.c(1734): AH00927: initializing worker proxy:reverse local
[Tue Dec 17 14:11:46.668832 2013] [proxy:debug] [pid 29460] proxy_util.c(1785): AH00931: initialized single connection worker in child 29460 for (*)
[Tue Dec 17 14:11:46.668921 2013] [:info] [pid 29460] mod_wsgi (pid=29460): Initializing Python.
[Tue Dec 17 14:11:46.685523 2013] [:info] [pid 29455] mod_wsgi (pid=29455): Attach interpreter ''.
[Tue Dec 17 14:11:46.685687 2013] [:info] [pid 29455] mod_wsgi (pid=29455): Adding '/srv/www/poka/app/poka' to path.
[Tue Dec 17 14:11:46.685955 2013] [:info] [pid 29455] mod_wsgi (pid=29455): Adding '/srv/www/poka/app/env/main/lib/python2.7/site-packages' to path.
[Tue Dec 17 14:11:46.694283 2013] [:info] [pid 29458] mod_wsgi (pid=29458): Attach interpreter ''.
[Tue Dec 17 14:11:46.695044 2013] [:info] [pid 29456] mod_wsgi (pid=29456): Attach interpreter ''.
[Tue Dec 17 14:11:46.698253 2013] [:info] [pid 29457] mod_wsgi (pid=29457): Attach interpreter ''.
[Tue Dec 17 14:11:46.702979 2013] [:info] [pid 29459] mod_wsgi (pid=29459): Attach interpreter ''.
[Tue Dec 17 14:11:46.711173 2013] [:info] [pid 29460] mod_wsgi (pid=29460): Attach interpreter ''.
EDIT #2 My wsgi.py
"""
This module contains the WSGI application used by Django's development server
and any production WSGI deployments. It should expose a module-level variable
named ``application``. Django's ``runserver`` and ``runfcgi`` commands discover
this application via the ``WSGI_APPLICATION`` setting.
Usually you will have the standard Django WSGI application here, but it also
might make sense to replace the whole Django WSGI application with a custom one
that later delegates to the Django one. For example, you could introduce WSGI
middleware here, or combine a Django application with an application of another
framework.
"""
import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings.prod")
# This application object is used by any WSGI server configured to use this
# file. This includes Django's development server, if the WSGI_APPLICATION
# setting points here.
import djcelery
from django.core.wsgi import get_wsgi_application
djcelery.setup_loader()
_application = get_wsgi_application()
env_variables_to_pass = ['AWS_ACCESS_KEY_ID', 'AWS_SECRET_ACCESS_KEY']
def application(environ, start_response):
# pass the WSGI environment variables on through to os.environ
for var in env_variables_to_pass:
os.environ[var] = environ.get(var, '')
return _application(environ, start_response)
EDIT #3: Logs from logs/error_log
[Thu Dec 19 18:05:58.247406 2013] [auth_digest:notice] [pid 1733] AH01757: generating secret for digest authentication ...
[Thu Dec 19 18:05:58.248882 2013] [lbmethod_heartbeat:notice] [pid 1733] AH02282: No slotmem from mod_heartmonitor
[Thu Dec 19 18:05:58.300894 2013] [ssl:warn] [pid 1733] AH02292: Init: Name-based SSL virtual hosts only work for clients with TLS server name indication support (RFC 4366)
[Thu Dec 19 18:05:58.591912 2013] [mpm_prefork:notice] [pid 1733] AH00163: Apache/2.4.6 (Amazon) OpenSSL/1.0.1e-fips mod_wsgi/3.4 Python/2.7.5 configured -- resuming normal operations
[Thu Dec 19 18:05:58.591987 2013] [core:notice] [pid 1733] AH00094: Command line: '/usr/sbin/httpd'
[Thu Dec 19 18:06:09.626354 2013] [core:notice] [pid 1733] AH00052: child pid 1735 exit signal Segmentation fault (11)
[Thu Dec 19 19:31:42.719739 2013] [:error] [pid 1755] (70007)The timeout specified has expired: [client 96.33.249.142:49830] mod_wsgi (pid=1755): Unable to get bucket brigade for request.
[Thu Dec 19 19:31:43.195999 2013] [:error] [pid 1769] [client 96.33.249.142:29054] mod_wsgi (pid=1769): Exception occurred processing WSGI script '/srv/www/poka/app/poka/apache/wsgi.py'.
[Thu Dec 19 19:31:43.196140 2013] [:error] [pid 1769] [client 96.33.249.142:29054] IOError: failed to write data
When i had this error it was cause i was sending multi-part data though post, and fixed it by changing <form method="POST"> to <form method="POST" enctype="multipart/form-data">