HTTP 504 Gateway Timeout
The server, while acting as a gateway or proxy, did not receive a timely response from the upstream server.
5xx Server Error
504
Gateway Timeout
Description
The 504 Gateway Timeout status code indicates that the server, while acting as a gateway or proxy, did not receive a timely response from an upstream server it needed to access in order to complete the request. This is different from 408 Request Timeout, which is about the client not sending the request in time. The 504 specifically indicates that a gateway, proxy, or load balancer timed out while waiting for a response from the upstream server. This often points to the upstream server being overwhelmed, having performance issues, or network connectivity problems between the gateway and the upstream server.
When Is It Used?
Encountered when a reverse proxy, load balancer, or API gateway times out waiting for the upstream application server to respond. Common causes include long-running database queries, resource-intensive computations, or network issues between the proxy and the application server.
Example Response
HTTP/1.1 504 Gateway Timeout
Content-Type: text/html
<h1>504 Gateway Timeout</h1>
<p>The upstream server did not respond in time.</p>Related Status Codes
502
Bad Gateway
The server, while acting as a gateway or proxy, received an invalid response from the upstream server.
503
Service Unavailable
The server is currently unable to handle the request due to temporary overload or maintenance.
408
Request Timeout
The server timed out waiting for the client to send the request.