How do I fix error 1078#0? Bad Gateway nginx/1.4.6 (Ubuntu)?

Hello guys and girls,

I am getting an error 1078#0 while trying to get my website up and going. Let me give you a chronology of events plus an error log:

I first brought Putty up and went to access my server. I got the Django “It Worked!” message.

After that I went to upgrade my Django and it updated to 1.11. i ran, in the Putty command, “service gunicorn restart”.

Got 502 Bad Gateway

I unistalled Django and was back to version 1.6.1. Refreshed. “Internal Server Error”

So i “pip install django==1.9” and checked version to ensure i was running Django 1.9. “service gunicorn restart”. Restarted. Refreshed. 502 Bad Gateway Error nginx/1.4.6 (Ubuntu).

Here are the errors I am getting when I run “tail -f /var/log/nginx/error.log”: [error] 1078#0: *263 connect() failed (111: Connection refused) while connecting to upstream, client: XX.XXX.XXX.XX, server: _, request: “GET / HTTP/1.1”, upstream: “”, host: “XXX.XXX.X.XX”

Can someone please tell me what is going on here and why? It is very frustrating and getting this website up is mission critical as I have just filed my company and am ready to begin operation.

Submit an answer

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!

Sign In or Sign Up to Answer

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Hi @dayscue

We need the error log from Gunicorn, since that’s the service not running - Nginx only return the default 502 Bad Gateway, since it cannot connect to anything. It’s normally located in /var/log/upstart/gunicorn.log but you might run it with a different job name and then you have to look for /var/log/upstart/$JOB_NAME.log.

EDIT: But if you don’t see any logs, then you might need to update your Gunicorn script to include the --error-logfile /path/to/log/file:

But since you haven’t used the server yet, then you could just rebuild it (you will lose all data on the server) back to the Django One-Click. If you want to rebuild, go to the DigitalOcean control panel, click the droplet, click the Destroy menu on the left, search for “Django”, select the image and click Rebuild.