Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I've got an Ubuntu server configured with Nginx and uWSGI to serve Django which was setup and working with the default start page yesterday.

All I have done since is install MySQL and later PostgreSQL and add Db settings to Django and now I get a 502 Gateway Error and the upstream prematurely closed connection while reading response header from upstream error in my uwsgi error log.

I have had a look around and I've seen people suggest this can relate to a timeout setting and also that people have fixed it simply by reinstalling PHP, but I'd like to understand what exactly this means and hopefully how to fix it. Could someone possibly shed some light on this for me?

My uWSGI config looks like this;

# config
plugins = python
master = true
protocol = uwsgi
env = DJANGO_SETTINGS_MODULE=%(projectname).settings
pythonpath = %(base)/src/%(projectname)
module = %(projectname).wsgi
socket = 127.0.0.1:8889
logto = %(base)/logs/uwsgi.log
daemonize = /var/log/uwsgi/mydomain.log

And my Nginx config looks like this;

server {
    listen 80;
    server_name mydomain.com www.mydomain.com;
    root /var/www/mydomain.com/src/wdsclients;
    #access_log /var/www/mydomain.com/logs/access.log;
    error_log /var/www/mydomain.com/logs/error.log;
    server_tokens off;

    location /startic/ { #STATIC_URL
            alias /var/www/mydomain.com/src/static/; # STATIC_ROOT
            expires 30d;
    }

    location /media/ { # MEDIA_URL
            alias /var/www/mydomain.com/src/media/; # MEDIA_ROOT
            expires 30d;
    }

    location / {
            include uwsgi_params;
            uwsgi_pass 127.0.0.1:8889;
    }
}
share|improve this question
    
where is uwsgi_pass directive in your config? –  cadmi Apr 13 '13 at 12:43
    
@cadmi sorry - my terminal didn't have enough lines to copy/paste it all out and I missed that off. It's in location / { - I've updated my question. –  marksweb Apr 13 '13 at 13:00
    
try to add uwsgi_modifier1 30; after include uwsgi_patams; –  cadmi Apr 13 '13 at 15:02
    
do you run manage.py syncdb after db settings has been added to settings.py? –  cadmi Apr 13 '13 at 15:05

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.