HTTP status · 5xx — server error

502 Bad Gateway

502 Bad Gateway means a gateway or proxy received an invalid response from the upstream server.

Key facts

Class5xx — server error
StandardRFC 9110 §15.6.3
Cacheable by defaultNo
CauseInvalid response from upstream
Typical layerReverse proxy, CDN, load balancer

What 502 means

While acting as a gateway or proxy, the server received an invalid response from an upstream it needed to complete the request. The upstream may have crashed, closed the connection mid-response, spoken the wrong protocol, or sent malformed headers. The client's request was fine; the failure is between two servers.

Common causes

Check proxy error logs first — they usually name the upstream and the reason. A 502 that appears right after a deploy often means the app has not finished starting or a health check is failing.

Frequently asked questions

What is the difference between 502 and 504?

502 means the upstream returned an invalid response. 504 means the upstream did not respond in time.

Is 502 caused by the client?

Usually not. It is a server-to-server failure between a proxy and its upstream, though an oversized or malformed request can sometimes trigger a proxy error.

New tools, straight to your inbox

One short email when we add tools worth using. No spam, unsubscribe anytime.