HTTP 502 — Bad Gateway

The server was acting as a gateway or proxy and received an invalid response from the upstream server

When to use it

Use status 502 when this is the correct HTTP response semantic: The server was acting as a gateway or proxy and received an invalid response from the upstream server

Request and response example

GET /payments HTTP/1.1
Host: api.example.com

HTTP/1.1 502 Bad Gateway

Related status codes

500, 501, 503, 504

References

MDN · RFC 9110