1π
β
The issue is you are creating the Socket file in different location and pointing the nginx to different location. Your socket file is created at
/run/gunicorn.sock
as you can see from this command
ExecStart=/root/myproject/myprojectenv/bin/gunicorn --access-logfile - --workers 3 --bind unix:/run/gunicorn.sock myproject.wsgi:application
and referring to it in different location(/root/myproject/myproject.sock
) in nginx configuration as you can
see here
proxy_pass http://unix:/root/myproject/myproject.sock;
You can solve this in 2 ways
- by changing gunicorn conf from
ExecStart=/root/myproject/myprojectenv/bin/gunicorn --access-logfile - --workers 3 --bind unix:/run/gunicorn.sock myproject.wsgi:application
to
ExecStart=/root/myproject/myprojectenv/bin/gunicorn --access-logfile - --workers 3 --bind unix:/root/myproject/myproject.sock myproject.wsgi:application
- By changing nginx conf from
proxy_pass http://unix:/root/myproject/myproject.sock;
to
proxy_pass http://unix:/run/gunicorn.sock;
I recommend using the first approach
Restart both gunicorn and nginx after these changes
π€Abhinav Dev
Source:stackexchange.com