502 Bad Gateway
A gateway/proxy (nginx, Cloudflare) got an invalid response from the upstream app.
Common causes
- A proxy / CDN (Nginx, Cloudflare, IIS ARR) got no valid response from the upstream server
- The upstream app stopped, crashed or answered with the wrong protocol
How to fix
- Check the upstream app is running (PM2, systemd, app pool)
- Compare the upstream port / address in the proxy configuration
- Read the proxy and app logs for the same moment
Detailed reference (MDN) ↗RFC 9110 §15.6.3 ↗
Which code should I use?
- 502 / 504: Both come from a proxy / gateway. 502: the upstream server sent a bad response or refused the connection. 504: the upstream server was too slow (timed out).
