I’m deploying my Djano application on a VPS and I’m following the steps in the below link to configure my app with Gunicorn and Nginx.
How To Set Up Django with Postgres, Nginx, and Gunicorn on Ubuntu 16.04
Everything went well with the tutorial (gunicorn and nginx are running) but the issue is that when Im’ visiting the VPS through the static IP its showing a white screen that is always reloading.
After checking nginx log I found the following:
(13: Permission denied) while connecting to upstream, client: <client_ip>, server: <server_ip>, request: "GET / HTTP/1.1, upstream: "http://unix:/root/myproject/myproject.sock:/", host: "<server_ip>", referrer: "http://<server_ip>/"
2
Answers
After searching for roughly 7 hours, I was finally able to find a solution to this issue in the Nginx forum:
Nginx connet to .sock failed (13:Permission denied) - 502 bad gateway
What I simply did was changing the name of the user on the first line in
/etc/nginx/nginx.conf
file.In my case the default user was
www-data
and I changed it to myroot
machine username.In the top of nginx.conf file is a user name (user nginx;). just add this user in same group that your site or project is. www-data or any is yours. sorry for english.