Skip to main content
Kill -9 Club
Sign in

502 Bad Gateway

Diagnosis

An nginx error page, produced by nginx, saying the application behind it gave no usable answer. It is not a fault in the web server and not a fault in the panel: the proxy did its job, the thing it proxies to did not. The distinction that saves time separates 502 from 504. A 502 means the connection was refused or the reply was unusable — most often connect() failed (111: Connection refused) while connecting to upstream in /var/log/nginx/error.log. A 504 means the connection was accepted and no answer arrived inside proxy_read_timeout, sixty seconds by default. And a 502 with nothing at all in sudo journalctl -u myapp means the request never reached your code: reading it as an application bug sends you hunting through a program that was never called. Start with sudo ss -tlnp | grep 3000.

Also written: 502, bad gateway, upstream error