Rebooted server via ubuntu command line, now website returns 502

March 6, 2019 1.7k views
Nginx Python Django Ubuntu 18.04

My website has been running since I deployed it yesterday.
I rebooted the server this morning, and now the website won’t load.
Im using nginx and gunicorn - i have tested both and the tests were successful.

What reasons are there that the website now wont load, after nothing was changed during the reboot

1 Answer

502 Bad Gateway means nginx is unable to communicate to gunicorn.

Make sure that gunicorn is running on the expected port. You can verify it using :

netstat -tulpn

If you find it running and the website still shows 502, try restarting nginx and gunicorn.

Let me know if you have any further questions.

  • I can’t see gunicorn in the table (posted below), i’m assuming that’s the issue? It’s strange as when I run sudo systemctl status gunicorn.socket, it says gunicorn is active

    Active Internet connections (only servers)
    Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
    tcp 0 0* LISTEN 1849/nginx: master
    tcp 0 0* LISTEN 718/systemd-resolve
    tcp 0 0* LISTEN 997/sshd
    tcp 0 0* LISTEN 1037/postgres
    tcp 0 0* LISTEN 1849/nginx: master
    tcp6 0 0 :::80 :::* LISTEN 1849/nginx: master
    tcp6 0 0 :::22 :::* LISTEN 997/sshd
    udp 0 0* 718/systemd-resolve

    • What errors you find with “tail -F /var/log/nginx/error.log”

      Probably there is a problem with the sock file.

Have another answer? Share your knowledge.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!