HTTP Status Codes

HTTP 502 Bad Gateway

502
HighWeb ServerReference page

Bad Gateway — the server received an invalid response from an upstream server

A 502 Bad Gateway response appears in multi-server architectures where one server accepts the client request and then depends on another server behind it. The gateway or proxy is reachable, but the upstream answer it received was invalid, incomplete, or otherwise unusable.

Visual summary

A quick reference view of how HTTP 502 appears when a reachable gateway or proxy cannot use the upstream response it received.

HTTP 502 visual summary showing a gateway receiving an unusable upstream response from another server
Visual summary: 502 means the client reached one server, but that server could not pass along a valid answer from another server behind it.

What 502 Means

The shortest useful reading of this status code.

Bad Gateway means the server received an invalid response from an upstream server.

For gateway failures, the key distinction is that one server did answer the client but could not obtain a usable upstream response from another server behind it.

Quick read

Gateway got a bad upstream result

A 502 means an edge, proxy, or gateway server could not use the upstream response it received.

Technical Context

How this status behaves without turning the page into a repair guide.

Gateway hop

A 502 only makes sense when at least two servers are involved in the request path. One server is acting as the public-facing gateway, proxy, or edge layer, and another server behind it is expected to provide the real upstream answer.

Invalid upstream response

Its key contrast is with 500 and 504. A 500 points to an internal application failure on the server handling the request directly, while a 504 points to an upstream timeout where no usable response arrived in time. A 502 sits in the middle: the gateway got something back or reached the next hop, but the result was not a valid response it could present to the client.

Proxy chain

This is why 502s often appear around restarts, deploy windows, proxy misrouting, and unstable backend health rather than around one permanently missing URL.

Related HTTP Codes

Nearby HTTP status codes help clarify how 502 differs inside the same response family.

Common Causes

Reverse proxy receives a malformed upstream response

The front server can talk to the backend, but the response it got back is incomplete, invalid, or unusable.

Upstream application closes the connection too early

The gateway begins the handoff, but the backend drops out before finishing a valid HTTP response.

Gateway points to an unhealthy or restarting backend

The proxy route exists, but the next server in the chain is not producing a usable answer yet.

Name resolution or network path to the upstream breaks mid-hop

The failure occurs between cooperating servers rather than between the browser and the first server.

Typical Scenarios

01

A reverse proxy forwards traffic correctly but the backend crashes before finishing a valid HTTP response

02

A load balancer reaches a backend that is restarting or marked unhealthy during a deployment window

03

An edge service can accept the request but cannot complete a clean handoff to the origin service behind it

What To Know

A 502 usually reflects a server-to-server handoff problem rather than a client-side mistake or one missing page. If many pages show 502 at once, the broader pattern usually points to a shared upstream service, proxy route, or deployment event affecting multiple requests at the same time.

Frequently Asked Questions

Common interpretation questions about HTTP 502.

A 500 is an internal failure on the server handling the request. A 502 means a gateway or proxy could not use the response it got from another server behind it.

A 502 means the upstream result was invalid or unusable. A 504 means the upstream did not answer within the allowed time window.

Deployments can briefly route traffic to backends that are restarting, unhealthy, or not yet ready to produce complete responses, which makes gateway layers return 502.