Home > front end >  connect() to unix:/home/glenn/blog.sock failed (13: Permission denied) while connecting to upstream
connect() to unix:/home/glenn/blog.sock failed (13: Permission denied) while connecting to upstream

Time:08-13

I am following this tutorial to deploy my django project using gunicorn on an ubuntu 22.04 server, and I think my configuration file is okay. However when I try to go to my Ip address on the server I get a 502 getway error. When I check the error log, I get the following output:

2022/08/09 22:05:36 [crit] 7960#7960: *5 connect() to unix:/home/glenn/blog.sock failed (13: Permission denied) while connecting to upstream, client: 197.231.183.74, server : 67.205.168.227, request: "GET / HTTP/1.1", upstream: "http://unix:/home/glenn/blog.s ock:/", host: "67.205.168.227"

I have followed the documentation to check for possible troubleshooting guides, and I have been advised to check for my permissions. On doing so, I get the following error log

drwxr-xr-x root  root     /
drwxr-xr-x root  root     home
drwxr-x--- glenn glenn    glenn
srwxrwxrwx glenn www-data blog.sock

So does anyone know of a specific command I can use to edit the permissions? Or how I can edit my /etc/nginx/sites-available/blog file to change the permissions

here is how my /etc/nginx/sites-available/blog file looks like


server {
        listen 80;
        server_name 67.205.168.227;

        location = /favicon.ico { access_log off; log_not_found off; }
        location /static/ {
                root /home/glenn/blog;
        }

        location /media/ {
                root /home/glenn/blog;
     }

        location / {
                include proxy_params;
                proxy_pass http://unix:/home/glenn/blog.sock;
        }
}

Here is my gunicorn.service file

[Unit]
Description=gunicorn daemon
Requires = gunicorn.socket
After=network.target

[Service]
User=glenn
Group=www-data
WorkingDirectory=/home/glenn/blog
ExecStart=/home/glenn/blog/env/bin/gunicorn \
        --access-logfile - \
        --workers 3 \
        --bind unix:/home/glenn/blog.sock \
        blog.wsgi:application

[Install]
WantedBy=multi-user.target

This is ubuntu 22.04.

CodePudding user response:

So I discovered that the problem is that I was running debug as True (You cannot run with debug on while in production) And then I also changed the read/write permissions since the user needs to have access to all the files within the directory, by using the command chmod og x /home/lamnk

  • Related