504 Gateway Timeout
A gateway or proxy did not get a response from the upstream server in time.
| Class | Server error (5xx) |
|---|---|
| Defined in | RFC9110, Section 15.6.5 |
| Cacheable by default | No, unless explicit freshness headers allow it |
Common causes
- The upstream server took too long to answer the gateway.
- A slow database query or an external API call that hangs.
What to do
Optimize the slow operation or raise the gateway timeout if that is reasonable. Check network paths between proxy and backend.
Related codes
- 502 Bad Gateway: A gateway or proxy received an invalid response from the upstream server.
- 503 Service Unavailable: The server is not ready to handle the request, often because of overload or maintenance.
- 408 Request Timeout: The server timed out waiting for the request to be sent in full.