tool::http-status-detail
504 Gateway Timeout
The gateway did not receive a timely response from an upstream server.
Status Code
504
Name
Gateway Timeout
Category
5xxDetailed Explanation
HTTP 504 Gateway Timeout indicates that a gateway or proxy server did not receive a timely response from an upstream server. Unlike 502 (which signals a bad response), 504 means no response arrived at all within the timeout window. It commonly occurs when a slow database query or external API call causes the upstream server to miss the proxy's timeout.
Common Causes
- ▸The upstream server is delayed by a slow database query
- ▸The upstream processing time exceeds the proxy's configured timeout
- ▸The upstream server is overloaded and responding slowly
- ▸An external API call is blocking the entire request pipeline
- ▸Network congestion is delaying packet delivery between servers
How to Fix
- 1.Increase Nginx's proxy_read_timeout and proxy_connect_timeout values
- 2.Optimize slow database queries (analyze execution plans)
- 3.Check upstream server load and consider scaling out
- 4.Apply timeout and circuit-breaker patterns to external API calls
- 5.Offload long-running tasks to async queues and worker processes
Related HTTP Headers
Retry-AfterServerResponse Example
HTTP/1.1 504 Gateway Timeout Server: nginx/1.24.0 Content-Type: text/html <html><body><h1>504 Gateway Timeout</h1><p>The upstream server did not respond in time.</p></body></html>
Related Status Codes
500Internal Server ErrorThe server encountered an unexpected condition.→501Not ImplementedThe server does not support the requested functionality.→502Bad GatewayThe gateway received an invalid response from an upstream server.→503Service UnavailableThe server is temporarily unable to handle the request.→505HTTP Version Not SupportedThe HTTP version used in the request is not supported.→
ad · 300×250
// related tools