The HTTP 504 (Gateway Timeout) status code means that a server acting as a gateway or proxy did not receive a timely response from an upstream server it needed to reach to complete the request, according to RFC 9110, the IETF standard that defines HTTP semantics. In the words of Section 15.6.5 of RFC 9110, "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."
Who sends a 504
Section 3.7 of RFC 9110 names three common forms of HTTP intermediary: proxy, gateway and tunnel. A proxy is a forwarding agent the client chooses, usually through local configuration rules. A gateway, also called a reverse proxy, acts as an origin server toward the client but forwards requests inbound to another server or servers, and the same section says gateways are often used for "accelerator" caching and to spread HTTP services across multiple machines for load balancing.
How 504 compares with nearby codes
RFC 9110 puts 504 in the 5xx (Server Error) class, which means the server is aware that it has erred or is incapable of performing the requested method. Nearby codes differ in who failed and how.
| Code | Name | What RFC 9110 says it means |
|---|---|---|
| 504 | Gateway Timeout | A gateway or proxy did not receive a timely response from an upstream server |
| 502 | Bad Gateway | A gateway or proxy received an invalid response from an inbound server |
| 503 | Service Unavailable | The server cannot handle the request now because of a temporary overload or scheduled maintenance |
| 500 | Internal Server Error | An unexpected condition prevented the server from fulfilling the request |
| 408 | Request Timeout | The server did not receive a complete request message within the time it was prepared to wait |