Killerbrine06
Killerbrine06

Reputation: 1

NGINX UWSGI Permission Denied

Using:

I am trying to deploy a Django website on my VPS using uwsgi and nginx but I keep getting 502 error code. In nginx error.log file I have the following exception: *543 connect() to unix:/root/uwsgi/testproject.sock failed (13: Permission denied) while connecting to upstream

The project structure is as follows:

wsgi file: root/html/testproject/testproject/wsgi.py

uwsgi ini: root/uwsgi/sites/testproject.ini

socket: root/uwsgi/testproject.sock

Note: I have used the root user during the whole setup.

testproject.ini

[uwsgi]
chdir=/root/html/testproject
wsgi-file=/root/html/testproject/testproject/wsgi.py
socket=/root/uwsgi/testproject.sock
chmod-socket=666
uid=www-data
gid=www-data

master=True
pidfile=/tmp/project-master.pid
vaccum=True
max-requests=5000
daemonize=/tmp/uwsgi.logs

/etc/nginx/sites-available/testproject

server{
        listen 80;
        server_name 85.31.237.228;

        location / {
                include uwsgi_params;
                uwsgi_pass unix:/root/uwsgi/testproject.sock;
        }
}

Can someone please help me figure out what I'm doing wrong?

I have switched between 666 and 644 for chmod param but nothing worked.

Upvotes: 0

Views: 68

Answers (1)

MecaTheclau
MecaTheclau

Reputation: 308

Try ls /root/uwsgi/testproject.sock to see if the socket is created. Run ls -l /root/uwsgi/ to check who owns the .sock file. Run ls -l /root/ to see who owns uwsgi and make sure the www-data user has access to the .sock file. You can try to run uwsgi config as root and then see if it can work

Upvotes: 0

Related Questions