By crstuart
Hi i followed along on the great tutorial here:
And i was able to get things working on both a test server and on my live website.
But after a few days i got a 502 Bad Gatway Error on my domain.
I’ve spent the last two days trying to fix the problem to no avail. I’m assuming its some sort of permissions issue between NGINX and Gunicorn but have no idea what the problem might be.
The gunicorn error log is saying that it can’t connect to the sock file.
The NGINX error log is showing a connect to sock failed error.
I’ve tried to change firewall settings, user permissons, paths everything it seems and still not working.
Anyone have any idea what might be the issue here?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Seems like the problem is in Gunicorn, so focus on that only. What’s your Gunicorn socket file path? Seems like that’s the common problem - as described in length here: http://stackoverflow.com/questions/28689445/nginx-django-and-gunicorn-gunicorn-sock-file-is-missing
okay so i changed the directory —per some recommendations in another post about security to this:
unix:/var/log/gunicorn/chrisblog.sock
here is my full gunicorn.service file:
[Unit]
Description=gunicorn daemon
After=network.target
[Service]
User=django
Group=www-data
WorkingDirectory=/home/django/chrisblog
ExecStart=/home/django/chrisblog/myprojectenv/bin/gunicorn --workers 3 --bind unix:/var/log/gunicorn/chrisblog.sock chrisblog.wsgi$
[Install]
WantedBy=multi-user.target
and here is my nginx file
server {
listen 80;
server_name 45.32.201.31 pythoncreate.com;
location = /favicon.ico { access_log off; log_not_found off; }
location /static/ {
root /home/django/chrisblog;
}
location / {
include proxy_params;
proxy_pass http://unix:/var/log/gunicorn/chrisblog.sock;
}
}
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.