Summary of problem
- Getting a “502 Bad Gateway - nginx/1.14.0 (Ubuntu)” error when visiting my live site.
- Only able to access site through a development server port: python3 manage.py runserver 0.0.0.0:8080
- I can then access my site via www.myproject.com:8080 and everything works as it should
- I believe it has to do with gunicorn's inability to serve my project
Technologies
- python3
- django version 2.1.2
- Digitalocean
Workflow up to the point of error
- Created a droplet on digital ocean - following this guide https://www.youtube.com/watch?v=Y-CT_l1dnVU&t=958s
- It seems many people in the comment section of that guide are experiencing the same issue
- Used digital ocean’s one click install for django
- Before uploading my project files I checked the live site to see that everything was in order, it was.
- Uploaded my project files and upgraded django
- Checked live site again, got the ‘502 Bad Gateway’ error
- Tried switching back to the old version of django, that wasn’t the issue
- Followed this guide: https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-ubuntu-16-04 and found that my gunicorn daemon is failing to start
sudo nano /etc/systemd/system/gunicorn.service
- checked status of gunicorn
sudo systemctl status gunicorn
- Checked error logs:
sudo journalctl -u gunicorn
Any help would be greatly appreciated