HTTP status · 5xx — server error
504 Gateway Timeout
504 Gateway Timeout means a gateway or proxy did not receive a timely response from an upstream server.
Key facts
| Class | 5xx — server error |
|---|---|
| Standard | RFC 9110 §15.6.5 |
| Cacheable by default | No |
| Cause | Upstream did not answer within the proxy timeout |
| Typical layer | Reverse proxy, CDN, load balancer |
What 504 means
The proxy waited for an upstream response and gave up. The upstream may be slow, stuck, or unreachable in a way that produces no response at all. The client's request may have reached the upstream and may even still be running — a 504 is a statement about the proxy's patience, not about the final outcome.
How to diagnose a 504
- Find the proxy timeout setting and compare it with the upstream's typical latency.
- Check whether the upstream is blocked on a slow query, a lock, an external API or a cold start.
- Look for a mismatch: the proxy times out at 30 seconds while the app's own timeout is 60 seconds, so the app keeps working after the client has gone.
- If the endpoint is legitimately long-running, move it to an asynchronous job instead of raising the timeout indefinitely.
Frequently asked questions
What is the difference between 504 and 502?
502 means the upstream sent an invalid response. 504 means it sent no timely response at all.
Did my request succeed if I get a 504?
Possibly. A 504 is the proxy giving up, not necessarily the upstream failing. Check the upstream logs or state before retrying a non-idempotent request.
Why does a 504 appear only for some users?
Timeouts are sensitive to latency and load. A slow query or a cold backend can affect only the requests that hit the overloaded path or region.