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
Go HTTP Status Constant
Symfony HTTP Status Constant
Python2 HTTP Status Constant
Python3+ HTTP Status Constant
Python3.5+ HTTP Status Constant
Apache HttpComponents Core
504 status code example
Here is an example of a request and response that could result in a 504 status code:
GET https://example.com/api/data HTTP/1.1
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
HTTP/1.1 504 Gateway Timeout
Content-Type: text/html; charset=UTF-8
Date: Wed, 16 Mar 2023 12:00:00 GMT
<head><title>504 Gateway Timeout</title></head>
<center><h1>504 Gateway Timeout</h1></center>
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.
- Learn about web development
- Learn about SEO
- Web development services from WebFX
- SEO services from WebFX
- MDN Web Docs