HTTP 502 — Bad Gateway
Category: HTTP | Priority: High
What does HTTP 502 Bad Gateway mean?
A reverse proxy or gateway received an invalid upstream response or could not establish a valid connection to an application server.
Likely causes of HTTP 502
- Application backend unavailable or refusing connections
- Wrong upstream host, port or HTTP/HTTPS protocol
- Broken TLS negotiation or name resolution
- Unexpected connection resets or malformed upstream responses
How to diagnose and fix HTTP 502
- Capture the affected URL, timestamp and request identifier.
- From the proxy, test the backend host, port and HTTP/HTTPS protocol.
- Correlate reverse-proxy errors with application and network logs.
- Review recent configuration or certificate changes, then correct the root cause.
- Retest the full request path and confirm a valid upstream response.
Preserve logs before restarting services. Do not expose internal URLs, access tokens or passwords in screenshots.
Return to the HTTP error code reference.
HTTP 502 vs 504: what is the difference?
A 502 usually indicates an invalid or unusable upstream response. A 504 indicates the upstream server did not respond before the configured timeout. Both may involve a reverse proxy, but their diagnosis differs.