504 Gateway Timeout
HTTP response status code 504 Gateway Timeout is a server error message that is returned to indicate that it is acting as a proxy or gateway, and it has received no HTTP response from the upstream server.
Usage
When the 504 Gateway Timeout status code is received, the server is first indicating that it is acting as a proxy or gateway for an upstream server. After the HTTP request has been received, an attempt to forward it to the upstream server was made but no HTTP response was received.
This is related to error 502 Bad Gateway status code, except, in that case, the server returns an invalid HTTP response or is otherwise misbehaving.
Example
In the example, the client requests a resource and the server responds with a 504 Gateway Timeout status code because the server that it attempted to retrieve the resource from did not return a HTTP response.
Request
GET /news HTTP/1.1
Host: www.example.re
Response
HTTP/1.1 504 Gateway Timeout
Content-Type: text/html; charset=UTF-8
Content-Length: 134
<html>
<head>
<title>Gateway Timeout<\title>
</head>
<body>
<p>The server is is not responding.</p>
</body>
</html>
Code references
.NET
HttpStatusCode.GatewayTimeout
Rust
http::StatusCode::GATEWAY_TIMEOUT
Rails
:gateway_timeout
Go
http.StatusGatewayTimeout
Symfony
Response::HTTP_GATEWAY_TIMEOUT
Python3.5+
http.HTTPStatus.GATEWAY_TIMEOUT
Java
java.net.HttpURLConnection.HTTP_GATEWAY_TIMEOUT
Apache HttpComponents Core
org.apache.hc.core5.http.HttpStatus.SC_GATEWAY_TIMEOUT
Angular
@angular/common/http/HttpStatusCode.GatewayTimeout
Takeaway
The 504 Gateway Timeout status code is a server error that indicates an upstream server is not responding and the HTTP request cannot be completed.