Home > front end >  I'm getting the classic "Permission denied while connecting to upstream" while trying
I'm getting the classic "Permission denied while connecting to upstream" while trying

Time:02-18

I know the question has been asked a million times, and I've tried almost every 'solution' to no avail. I'm thinking that my problem could be unique.

uwsgi.ini:

module = wsgi:app
master = true
processes = 5
socket = elekto.sock
chmod-socket = 666
vacuum = true
die-on-term = true
logto = /home/richardgrecoson/elekto/elekto.log

/etc/nginx/sites-enabled/elekto :

server {
    listen 80;
    server_name my_ip;
location / {
        include uwsgi_params;
        uwsgi_pass unix:/home/richardgrecoson/elekto/elekto.sock;
    }
}

/etc/systemd/system/elekto.service

[Unit]
Description=uWSGI instance to serve myproject
After=network.target

[Service]
User=richardgrecoson
Group=www-data
WorkingDirectory=/home/richardgrecoson/elekto
Environment="PATH=/home/richardgrecoson/elekto/.venv/bin"
ExecStart=/home/richardgrecoson/elekto/.venv/bin/uwsgi --ini uwsgi.ini

[Install]
WantedBy=multi-user.target

CodePudding user response:

Your NGINX is not allowed to r/w/x on the socket file. Lets try some things.

Change the permission of the socket to 0777 and check it with ls /home/richardgrecoson/elekto/elekto.sock

In general it is important that the runuser of NGINX is allowed to r/w/x the socket. The runuser of nginx is "normally" nginx. Check this by typing ps -elf |grep nginx

If it is NGINX I would change the permissions of the socket back to 660 and change the user and group to nginx.

With this the nginx user will have access to the socket.

If you want to use a different runuser for the socket as for nginx, create a new user and add it to the nginx group usermod -a -G nginx yourusername. This will work with 660 as well.

  • Related