What 504 means
The load balancer or CDN waited for the application server and gave up. The server may still be working on (and may complete) your request.
Common causes
- A slow database query or upstream API call.
- An endpoint that does too much work per request.
- Network problems between the proxy and the server.
How to fix it
If you're calling an API
- Retry with backoff, but be careful with non-idempotent requests: the first one may have succeeded.
- Ask for smaller pages or narrower queries.
If you run the server
- Speed up the endpoint, raise proxy timeouts, or move slow work to a background job (202 + polling).
Should you retry?
Yes for idempotent requests; check before retrying writes.
Example response
HTTP/1.1 504 Gateway Timeout
Content-Type: application/problem+json
{
"type": "about:blank",
"title": "Gateway Timeout",
"status": 504,
"detail": "A proxy or gateway didn't get a response from the server in time."
}Defined in: RFC 9110 (HTTP Semantics). 504 is a server error: the problem is on the server's side.
Debugging an API call? Convert your request with the cURL converter, check the response with the JSON formatter, or see whether the API is down on its status page.