← All status codes
502

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

Application server crashed or isn't running
Application returned an invalid HTTP response
Upstream timeout (app took too long to respond)
Socket connection closed prematurely
Application out of memory

HOW TO FIX IT

Check if your application process is running
Check application logs for crashes
Increase upstream timeout in your reverse proxy
Check if the app is running out of memory or file descriptors

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

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.