Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

502 error with nginx + uwsgi +django

I've tried to configure django on top on nginx and uwsgi and a 502 bad gateway error is encountered when trying to access localhost

This is my /etc/ngingx/sites-available/default file

server {
    server_name testapp1.com www.testapp1.com;
    access_log /var/log/nginx/testapp1.com.access.log;

    location / {
        uwsgi_pass unix:///var/run/uwsgi/app/testapp1/socket;
        include uwsgi_params;
    }
}

This is my testapp1.ini file in /etc/nginx/apps-available/

[uwsgi]  
    thread=3  
    master=1  
    env = DJANGO_SETTINGS_MODULE=testapp1.settings  
    module = django.core.handlers.wsgi:WSGIHandler()  
    chdir = /home/paul/apps/testapp1  
    socket = /run/uwsgi/testapp1/socket  
    logto = /var/log/uwsgi/testapp1.log  

This is the uwsgi.log file

Tue Jul 10 21:49:38 2012 - *** Starting uWSGI 1.0.3-debian (32bit) on
[Tue Jul 10 21:49:38 2012] *** Tue Jul 10 21:49:38 2012 - compiled
with version: 4.6.2 on 20 February 2012 10:06:16 Tue Jul 10 21:49:38
2012 - current working directory: / Tue Jul 10 21:49:38 2012 - writing
pidfile to /run/uwsgi/app/testapp1/pid Tue Jul 10 21:49:38 2012 -
detected binary path: /usr/bin/uwsgi-core Tue Jul 10 21:49:38 2012 -
setgid() to 33 Tue Jul 10 21:49:38 2012 - setuid() to 33 Tue Jul 10
21:49:38 2012 - your memory page size is 4096 bytes Tue Jul 10
21:49:38 2012 - uwsgi socket 0 bound to UNIX address
/run/uwsgi/app/testapp1/socket fd 5 Tue Jul 10 21:49:38 2012 - bind():
No such file or directory [socket.c line 107]

I didnt change the nginx.conf file.

like image 604
Paulo Avatar asked Jul 11 '12 10:07

Paulo


1 Answers

Other case scenario is that it is a permission problem (not a socket path misspell like in your case). In that case u can add this to uwsgi ini file

[uwsgi]                                                                                                          
uid = www-data
gid = www-data
chmod-socket = 664
chown-socket = www-data
like image 113
zzart Avatar answered Oct 21 '22 09:10

zzart