502 error with nginx + uwsgi + django

I tried setting django on top to nginx and uwsgi, and when trying to access localhost

a bad gateway 502 error occurs,

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

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 July 10 21:49:38 2012 - *** Launch 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 dated February 20, 2012 10:06:16 Tue Jul 10 21:49:38
2012 - current working directory: / Tue July 10 21:49:38 2012 - writing
pidfile to / run / uwsgi / app / testapp1 / pid Tue Jul 10 21:49:38 pm 2012 -
detected binary path: / usr / bin / uwsgi-core Tue Jul 10 21:49:38 2012 -
setgid () until 33 W Jul 10 21:49:38 2012 - setuid () until 33 W Jul 10
21:49:38 2012 - your memory page size is 4096 bytes Tue July 10
21:49:38 2012 - uwsgi socket 0 is bound to a UNIX address
/ run / uwsgi / app / testapp1 / socket fd 5 W Jul 10 Jul 21:49:38 2012 - bind ():
There is no such file or directory [socket.c line 107]

I have not changed the nginx.conf file.

+7
source share
2 answers

The error message is clear enough:

 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] 

You see the difference between:

  socket = /run/uwsgi/testapp1/socket 

and

  uwsgi_pass unix:///var/run/uwsgi/app/testapp1/socket; 

?

Hint: / var / run / uwsgi / application / testapp1 / socket

+13
source

Another random scenario is that this is a permission problem (and not a socket error, as in your case). In this case, you can add this to the uwsgi ini file

 [uwsgi] uid = www-data gid = www-data chmod-socket = 664 chown-socket = www-data 
+23
source

All Articles