Bad Gateway
The server acting as a gateway got an invalid response from the upstream server. Your load balancer or reverse proxy (Nginx, Cloudflare) reached your application server, but the app returned garbage or didn't respond.
COMMON CAUSES
HOW TO FIX IT
What this means for monitoring
502 usually means your app is down or crashing, but your infrastructure (load balancer, CDN) is still up. The problem is behind the proxy.
Related status codes
5xx Server Error
Something went wrong on the server. The catch-all error. Could be an unhandled exception, a crashed process, or a bug. If you're seeing this in your monitoring, check your server logs.
The server can't handle the request right now. Usually means the server is overloaded or down for maintenance. Often temporary — check back in a few minutes. A Retry-After header may be present.
The gateway server didn't get a response from the upstream server in time. Your app is too slow or has hung. If you're seeing this in monitoring, the problem is usually in your application, not the gateway.
Cloudflare-specific. The origin server returned an unexpected response. Often means the origin is returning an empty response, a response that's too large, or an invalid HTTP response.
Cloudflare-specific. The origin server refused the connection. Your server is down, firewalling Cloudflare's IPs, or not listening on the right port.
Cloudflare-specific. The TCP connection to the origin server timed out. The server is unreachable, overloaded, or there's a network issue between Cloudflare and your origin.
Cloudflare-specific. Cloudflare can't reach the origin server at all. DNS is pointing to the wrong IP, or the origin server is completely offline.
Get alerted when your endpoints return unexpected status codes.
Larm checks your HTTP endpoints from multiple global locations and alerts you when they return status codes outside your expected range.