502 Bad Gateway when following Django Nginx Ubuntu 16.04 guide

Posted November 18, 2016 3.2k views
PythonPostgreSQLDjangoPython FrameworksUbuntu 16.04

I’m following this guide. The development methods for serving my Django app work (using python runserver and gunicorn --bind myproject.wsgi:application), but when I set up the systemd and Nginx configuration files, I just get a 502 Nginx error page. I believe that Nginx is supposed to create the relevant .sock file at some point, but I don’t see one in my project directory.

Ultimately, I would actually like my Django app to be served on a subdirectory of the domain, like, since there is a website currently being served on the root domain.

Your help is greatly appreciated,


These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
2 answers

I have have exactly the same problem as well. A little help with be really appreciated.

stuck here too…really annoying