DEV Community 👩‍💻👨‍💻

Discussion on: Deploy Flask The Easy Way With Gunicorn and Nginx!

jishwin13 profile image

Hey, I followed the exact same steps but I am getting this error after I host it with nginx
12:10:20 [crit] 142389#142389: *1 connect() to unix:/root/status_report_automation/status_report_automation.sock failed (13: Permission denied) while connecting to upstream, client:, server: _, request: "GET / HTTP/1.1", upstream: upstream: "unix:/root/status_report_automatio...", host: ":8080"
Nginx is listening to port 8080

brandonwallace profile image
brandon_wallace Author • Edited on

It looks like you have put your project in the /root directory.

Enter fullscreen mode Exit fullscreen mode

It is better to put it in /var/www/ like this:

$ sudo mkdir /var/www/status_report_automation/
Enter fullscreen mode Exit fullscreen mode

Then set the correct permissions on the directory and files.

$ sudo chown -R $USER:www-data /var/www/status_report_automation/
Enter fullscreen mode Exit fullscreen mode

Make sure your systemd service file looks something like this in the service section:

ExecStart=/var/www/status_report_automation/.venv/bin/gunicorn --workers 3 --bind unix:/var/www/status_report_automation/status_report_automation.sock wsgi:app
Enter fullscreen mode Exit fullscreen mode