504

Gateway Timeout

Official
The parent server did not respond in a timely manner

General explanation of the 504 status code

The HTTP 504 Gateway Timeout error occurs when a server attempts to respond to a request from a client but is unable to do so within a reasonable amount of time. This error is usually referred to as a "gateway timeout" because it often occurs when a proxy server or gateway that mediates between the client and the server is unable to connect or receive a response from the server. This can be due to various reasons, such as server overload, network problems, or insufficient configuration of the proxy or gateway.

.

Specification of the HTTP status code 504

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.

Source / Quote by: The 504 Gateway Timeout HTTP Status Code is specified by section 6.6.5 of RFC7231.

How to throw a 504 statuscode with PHP?

To throw the HTTP status code 504 on a web page, the PHP function http_response_code can be used. The syntax is as follows: http_response_code(504) (PHP 5 >= 5.4.0, PHP 7, PHP 8)

Test the 504 HTTP status code

In order to be able to display the HTTP status code (in this case 504 Gateway Timeout) and other information on the client side, the development console must be opened with F12. Afterwards you have to navigate to the tab "Network". Now you can open the page, in the network tab you should see the web page (example index.php). This must be selected and then the Herder section must be selected. Here the user will see the following result:

Status code 504 Gateway Timeout
Overview
URL: https://http-statuscode.com/errorCodeExample.php?code=504
Status: 504 Gateway Timeout
Those: Network
IP address: XX.XX.XX.XX
Status code 504 Gateway Timeout

How do I solve the problem with the 504 status code?

There are several possible reasons why a HTTP error 504 Gateway Timeout "Gateway Timeout" may occur, such as:

  1. Server congestion: If a server receives too many requests and is unable to respond to them within a reasonable time, a timeout error may occur. This can be resolved by scaling the server or adding resources such as CPU, RAM, or storage.
  2. Network problems: a timeout error can also occur if there are problems with the network connection between the client and the server. This can be fixed by checking the network connection, checking router or firewall configurations, or restarting network components.
  3. Proxy or gateway issues: a gateway or proxy that mediates between the client and the server can also cause a timeout error. This can be fixed by checking and adjusting the proxy or gateway settings.
  4. Slow application or database: If an application or database is running slowly, this can also cause a timeout error. This can be fixed by optimizing the application or database.

To solve the problem, the following actions can be taken:

  1. Check the server status and make sure it is not overloaded.
  2. Check the network connection and make sure it is stable and reliable.
  3. Check the configuration of proxies or gateways and adjust them if necessary.
  4. Optimize the application or database to improve its performance.
  5. Restarting network components or servers can also help fix the problem.

In many cases, a combination of these measures can fix the problem.

How to create a custom error page for the 504 status code

Creating your own 504 Gateway Timeout error page is relatively easy with the web server "Apache" as well as with the web server "NGINX".

Apache Webserver

The web server "Apache" is one of the most popular web servers on the Internet. To create an own 504 Gateway Timeout error page in "Apache", the following change must be made in the following file.

File: .htaccess
ErrorDocument 504 /errors/504.html

NGINX Webserver

Similar to the web server "Apache", "NGINX" is also widely used on the Internet. To create your own 504 Gateway Timeout error page in "NGINX", the following change must be made in the following file.

File: sites-enabled/default
error_page 504 /504.html;
location = /504.html {
    root /usr/share/nginx/html;
    internal;
}

Browser compatibility of the 504 status code

Chrome no data
Edge no data
Firefox no data
Opera no data
Safari no data
Chrome Android no data
Firefox for Android no data
Opera Android no data
Safari on iOS no data
Internet no data
WebView Android no data

Constants in programming languages

HttpStatusCode.GatewayTimeout
http.StatusGatewayTimeout
Response::HTTP_GATEWAY_TIMEOUT
httplib.GATEWAY_TIMEOUT
http.client.GATEWAY_TIMEOUT
http.HTTPStatus.GATEWAY_TIMEOUT
:gateway_timeout
Author: Tony Brüser
Author: Tony Brüser

Tony Brüser is an enthusiastic web developer with a penchant for HTTP status codes.

LinkedInGitHub