Report this

What is the reason for this report?

New Django site on Nginx went to 502 few days after setup

Posted on February 9, 2017

I set up a django site on a new droplet with Uwsgi and Niginx a few days ago following this tutorial

https://www.digitalocean.com/community/tutorials/how-to-serve-django-applications-with-uwsgi-and-nginx-on-ubuntu-16-04

I had the site set up correctly with the Django ‘It worked’ message displaying and Nginx reporting everything was setup correctly.

I then came back to the site (nothing else was done to it) 2 days later to see a 502 message and also I was unable to ssh into the server. I had to reset the root pw and login via the console and set port 22 to allowed in ufw which I thought was strange as I had logged in and out via ssh many times when doing the setup a few days before.

Next I went through all the uwsgi and nginx config files and made sure everything was ok, nothing had been changed so I then restarted Nginx, still the site show 502, finally I ran this

sudo systemctl start uwsgi

and then the site was back to normal.

Does anyone know what caused this and is it going to happen again?

In the Nginx error logs I see something about the sock file:

connect() to unix:/run/uwsgi/firstsite.sock failed (2: No such file or directory) while connecting to upstream

but the sock file was created just fine the first time and was still there.

Also it was showing some errors referring to phpmyadmin e.g.

2017/02/09 07:06:49 [crit] 1615#1615: *47 connect() to unix:/run/uwsgi/firstsite.sock failed (2: No such file or directory) while connecting to upstream, client: 139.129.228.236, server: my-ip, request: "GET /phpmyadmin HTTP/1.1", upstream: "uwsgi://unix:/run/uwsgi/firstsite.sock:", host: "my-ip", referrer: "http://my-ip/phpmyadmin"

why is phpmyadmin there when this is a Django site?

thanks

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Start building today

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.