What Is a 504 Status Code?
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.
- Source: RFC7231 Section 6.6.5
504 CODE REFERENCES
Rails HTTP Status Symbol :gateway_timeout
Go HTTP Status Constant http.StatusGatewayTimeout
Symfony HTTP Status Constant Response::HTTP_GATEWAY_TIMEOUT
Python2 HTTP Status Constant httplib.GATEWAY_TIMEOUT
Python3+ HTTP Status Constant http.client.GATEWAY_TIMEOUT
Python3.5+ HTTP Status Constant http.HTTPStatus.GATEWAY_TIMEOUT
.NET HttpStatusCode.GatewayTimeout
Rust http::StatusCode::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
504 status code example
Here is an example of a request and response that could result in a 504 status code:
Request
GET https://example.com/api/data HTTP/1.1
Host: example.com
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.80 Safari/537.36
Response
HTTP/1.1 504 Gateway Timeout
Content-Type: text/html; charset=UTF-8
Retry-After: 30
Server: cloudflare
Date: Wed, 16 Mar 2023 12:00:00 GMT
Content-Length: 1433
<html>
<head><title>504 Gateway Timeout</title></head>
<body>
<center><h1>504 Gateway Timeout</h1></center>
<hr><center>cloudflare</center>
</body>
</html>
In this example, the client is attempting to access data from the example.com
API using an HTTP GET request. However, the server acting as a gateway or proxy has not received a timely response from an upstream server, resulting in a 504 Gateway Timeout error.
The server responds with an HTML page indicating the 504 error, along with some additional information, such as the server name, date, and the length of the response content. The Retry-After
header indicates that the client should wait for 30 seconds before retrying the request.
How to fix a 504 status code
To fix a 504 status code, you can try the following steps:
- Refresh the web page: Sometimes, a 504 error may be temporary, and refreshing the web page may resolve the issue.
- Check your internet connection: A poor internet connection or connectivity issues can also cause a 504 error. Try checking your internet connection and restarting your modem or router if needed.
- Clear your browser cache and cookies: Cached files or cookies may be causing conflicts with the website’s server, leading to a 504 error. Clearing your browser cache and cookies can help to fix the problem.
- Contact the website administrator: If the 504 error persists, it may be an issue with the website’s server. Contact the website administrator or technical support team to report the issue and get assistance.
- Wait it out: In some cases, a 504 error may be caused by high traffic or server overload. If this is the case, the best course of action may be to wait a few minutes and try again later.
What is the difference between a 504 status code and a 502 status code?
Both 502 and 504 status codes are related to server errors in the context of HTTP. However, they indicate different types of errors:
- 502 Bad Gateway: A 502 error occurs when a server acting as a gateway or proxy receives an invalid response from an upstream server it is trying to access to fulfill the request. This can happen, for example, if the upstream server is down or experiencing connectivity issues.
- 504 Gateway Timeout: A 504 error occurs when a server acting as a gateway or proxy does not receive a timely response from an upstream server it needs to access to fulfill the request. This can happen if the upstream server is taking too long to process the request or is experiencing high traffic.
In summary, a 502 error indicates a problem with the response received from an upstream server, while a 504 error indicates a problem with the lack of response from an upstream server.
Additional resources
- Learn about web development
- Learn about SEO
- Web development services from WebFX
- SEO services from WebFX
- MDN Web Docs
- W3Schools
Marketing Tips for Niche Industries
- Tourism/hospitality Statistics
- Treat More Patients with Healthcare Marketing Services
- Urgent Care Marketing Ideas: 5 High-ROI Tactics
- WebFX: Your Education Digital Marketing Agency
- Why Auto Part Retailers Need Digital Marketing
- Why Digital Marketing is Essential for Auctioneers
- Your Guide to Digital Marketing for Exercise Equipment Companies
- Your Guide to Digital Marketing for Industrial Repair Companies
- Vision Care Industry Statistics
- 10 Best Orthodontist Marketing Ideas to Earn More Patients