I am posting a question on behalf of my administrator. Basically he wants to set up Django app (made on Django 1.3, but will be moving to Django 1.4, so it should not really matter which one of these two will work, I hope) on WSGI on nginx, installed on Amazon EC2.

The app runs correctly when Django's development server is used (with ./manage.py runserver for example), also Apache works correctly. The only problem is with nginx and it looks there is something else wrong with nginx / WSGI or Django configuration.

His description is as follows:

Server has been configured according to many tutorials, but unfortunately Nginx and uWSGI still do not work with application.


import os, sys, wsgi

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "ProjectName.settings")

from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

I run uWSGI by comand:

uwsgi -x /etc/uwsgi/apps-enabled/projectname.xml

XML file:


In logs from uWSGI:

*** no app loaded. going in full dynamic mode ***

In logs from Nginx:

XXX.com [pid: XXX|app: -1|req: -1/1] XXX.XXX.XXX.XXX () {48 vars in 989 bytes} [Date] GET / => generated 46 bytes in 77 m
secs (HTTP/1.1 500) 2 headers in 63 bytes (0 switches on core 0)
added /usr/lib/python2.7/ to pythonpath.
Traceback (most recent call last):
  File "./ProjectName.py", line 26, in <module>
    from django.core.wsgi import get_wsgi_application
ImportError: No module named wsgi
unable to load app SCRIPT_NAME=XXX.com|

Example tutorials that were used:

Do you have any idea what has been done incorrectly, or what should be done to make Django work on uWSGI on nginx on EC2?

2 Answers 2


Tell him to start with simple configs and then tune them:


As soon as an app in simple http mode works, he can start adding integration with nginx.

After that he can starts real tuning adding processes and monitoring functions.

From what i can see it looks like he is starting in dynamic mode that is a really complex topic (and 99% of the time unneeded)


Add some more config lines to your uwsgi.xml, here is the yaml version from one of my projects:

    uid: 33
    gid: 33
    socket: /webapps/<project_name>/run/uwsgi-socket
    logto: /webapps/<project_name>/logs/uwsgi.log
    pidfile: /webapps/<project_name>/run/uwsgi.pid
    touch-reload: /webapps/<project_name>/run/reload
    enable-threads: true
    single-interpreter: true
    thread: 3
    master: true
    chdir: /webapps/<project_name>
    env: DJANGO_SETTINGS_MODULE=<project_name>.settings.production
    module: <project_name>.wsgi
    virtualenv: /webapps/.virtualenvs/<project_name>

It looks like you're missing the env and module sections. You might also want to consider a virtualenv as well.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.