HTTP · Bad Gateway

HTTP Error Code 502

A gateway or proxy received an invalid response from an upstream server.

errorLast verified 2026-11-08RFC 9110: HTTP Semantics
Quick answer

A gateway or proxy received an invalid response from an upstream server.

Code502
ProductHTTP
Company / originIETF / IANA · International standard
CategoryProtocols & Standards
Platform / versionsHTTP/1.1, HTTP/2, HTTP/3 · All HTTP versions
Severityerror
Official sourceRFC 9110: HTTP Semantics ↗
Last verified2026-11-08

What does HTTP error 502 mean?

HTTP 502 means the server acting as a gateway could not use the response it received from the upstream application or service. The upstream may have crashed, closed the connection, returned malformed headers, or spoken the wrong protocol.

Common causes

  • The upstream application process is down or restarting.
  • The upstream returned an invalid response, timed out mid-response, or reset the connection.
  • A proxy or load balancer points to the wrong port or protocol.

How to fix it

  1. Step 1

    Check the upstream service health and recent restarts.

  2. Step 2

    Inspect the gateway error log for the upstream address and failure reason.

  3. Step 3

    Verify that the proxy target port, protocol, and health check match the application.

When to escalate

Before you escalate: If the same status persists after you have checked the request, the server logs, and the upstream service, contact the API or hosting provider with the full response headers, request ID, timestamp, and a minimal reproduction.

Related codes

CodeNameWhat it means
504Gateway TimeoutA gateway or proxy did not receive a timely response from an upstream server.
400Bad RequestThe server cannot process the request because the syntax or parameters are invalid.
401UnauthorizedAuthentication is missing, expired, or invalid.
403ForbiddenThe server understood the request but refuses to authorize it.
404Not FoundThe requested resource does not exist at this URL.

Source & verification

This page was checked against RFC 9110: HTTP Semantics on 2026-11-08. The code, product, and platform fields are kept separate from the explanation so corrections can be made without changing the URL.

Open Error Codes is independent and not affiliated with IETF / IANA. Always confirm destructive or security-sensitive steps with the official documentation.