Reputation: 1170
I am trying to setup a simple flask application served by Nginx and Gunicorn and have mostly followed this tutorial. When trying to access the webpage, I get a 502 Bad Gateway error.
The nginx log (/var/log/nginx/error.log
) says :
[crit] 23472#0: *1 connect() to unix:/home/crawforc3/webpage/webpage.sock failed (13: Permission denied)
I checked and there is a webpage.sock
file in my project directory that looks like this:
srwxrwxrwx 1 crawforc3 www-data 0 May 31 17:59 webpage.sock
Here is my /etc/systemd/system/gunicorn.service
[Unit]
Description=gunicorn daemon
After=network.target
[Service]
User=crawforc3
Group=www-data
WorkingDirectory=/home/crawforc3/webpage
Environment="PATH=home/crawforc3/miniconda3/envs/HALSWEBPAGE/bin"
ExecStart=/home/crawforc3/miniconda3/envs/HALSWEBPAGE/bin/gunicorn --workers 3 --bind unix:/home/crawforc3/webpage/webpage.sock -m 007 wsgi:app
[Install]
WantedBy=multi-user.target
Upvotes: 5
Views: 1016
Reputation: 1170
I discovered that there was a discrepancy with /etc/nginx/nginx.conf
I had the user set as www-data and I should have set it as crawforc3. Making this change and restarting nginx and gunicorn resolved the issue.
Upvotes: 2