Rebooted server via ubuntu command line, now website returns 502

Posted March 6, 2019 2.3k views
NginxPythonDjangoUbuntu 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

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
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