A 504 Gateway Timeout error occurs when a server fails to receive a timely response from another server it is trying to communicate with. The error can be a frustrating experience for the website visitor, but also for website owners, as it leads to traffic loss and customer dissatisfaction and affects online reputation.
In this article, you will learn what the 504 Gateway Timeout error is and how you can fix it.
What Does 504 Gateway Timeout Mean?
The 504 Gateway Timeout error means that the server responsible for loading a website in your browser took too long to respond and failed to complete the request on time. When you try to visit a website, the browser sends a request to the web server hosting the site. In a successful scenario, the server returns a 200 OK status code and displays the web page.
However, if the server does not complete the request in the expected timeframe, the browser displays the 504 Gateway Timeout error. The error indicates that the server acting as a gateway or proxy failed to receive a prompt response from an upstream server required to fulfill the request.
Causes of 504 Gateway Timeout
There can be multiple causes of the 504 Gateway Timeout error. Some of them include a temporary traffic overload on the website or a resource taking too long to load.
The following are the most common causes of a 504 error:
- Firewall issues. Some firewalls block requests from specific ISPs or CDNs due to their DDoS protection and mitigation systems.
- Unresolvable domain. This is a domain that cannot be resolved to an IP address, resulting in the inability to access the website or associated service. The issue commonly happens if you have recently moved a website to a different IP address or hosting nameserver.
- Connectivity issues. Getting the error on multiple devices connected to a single network can result from temporary connection issues on your network equipment.
- Server overload. A web server running low on resources cannot handle an increase in traffic, causing it to overload and respond to requests slowly, which results in a 504 error.
- Insufficient PHP workers. PHP workers are processes or threads within a server environment that handle incoming requests and execute PHP scripts. If there are not enough PHP workers, the website might fail to process multiple requests.
- DNS issues. Some DNS (Domain Name System) issues include an incorrect DNS configuration or an outdated or corrupted DNS cache.
Note: Learn how to flush DNS cache in Windows, Linux, and macOS.
504 Bad Gateway Timeout Variations
The 504 error can manifest in different variations, contexts, and scenarios, depending on the browser, server, and operating system. However, despite the different variations, the 504 error is generally related to the server not receiving a timely response from an upstream server.
Following are the different variations of the 504 error:
- 504 Gateway Timeout NGINX
NGINX is a popular web server software that can act as a reverse proxy, load balancer, or HTTP cache. If NGINX does not receive a response from the upstream server within a specified time limit, it returns a 504 Gateway Timeout error to the client.
- Gateway Timeout Error
The gateway timeout error is another variation of the 504 error resulting from a request timeout.
- HTTP Error 504
Google Chrome can sometimes print the error description as HTTP ERROR 504. The code and the message appear that the requested site cannot be reached.
- Error 504 or 504 Error
On Android OS, the error can appear only as Error 504, with no additional information.
- 504 Gateway Time-out. The server didn’t respond in time.
The error states that the server did not respond in time, thus resulting in a 504 error.
- This site can't be reached. Domain took too long to respond.
The message "This site can't be reached. Domain took too long to respond" also indicates that the browser could not establish a connection to the requested domain within a reasonable timeframe.
- HTTP Error 504 - Gateway Timeout
The error may also appear on macOS as a variation shown in the screenshot below.
How to Fix 504 Gateway Timeout
In most cases, the cause of 504 errors is on the server side. Occasionally, the error may result from issues on the client side. This section of the article lists some basic troubleshooting steps for website visitors and website owners.
Refresh the Page
Refreshing the page resolves the 504 Error if the cause of the error is high traffic on the website. If the server is receiving more requests than it can handle, refresh the page to try and get the server to complete your request.
Refresh the page by clicking the Refresh button in your browser or press F5 on your keyboard. If you are using macOS, press the Cmd + R buttons. You can also clear the cache and force refresh the page by pressing Ctrl + F5.
Check Proxy Settings
Using a proxy server to browse the Internet privately could be the reason for a 504 error. Some proxy servers block access to certain web pages based on their IP address. Alternatively, incorrect proxy settings also lead to 504 errors.
Check if your proxy settings are causing the issue by disabling them on your machine and then reloading the page. For example, follow the steps below to disable the proxy in Windows:
1. Click the Start button and select the gear icon to open the Settings app.
2. Select the Network & Internet icon.
3. Select Proxy from the left pane and turn off the Use a proxy server switch.
4. Reload the website to see if the error is gone.
If the website is down only for you, and none of the solutions above work, incorrect settings or hardware issues may cause the 504 error. Try restarting your network device and then reloading the website to see if the error is gone.
Contact Website Admin
If the error persists and occurs on different devices and browsers, consider contacting the website administrators. If there is a 504 error on the website, they are likely already fixing it.
You can also check the website's social media accounts, if they have any, to see if there is any information on the issue.
Check Resource Usage
Website owners can check with the web host to see if their website has reached hosting plan limits. If that is the case, upgrading to a hosting plan that provides more resources to meet the website's needs is the solution.
Change PHP Execution Time
If the resource amount is not the cause of the 504 error, try extending the maximum execution time of PHP scripts. If a PHP script takes longer to execute than the defined duration, it can cause a server timeout error.
This troubleshooting step prevents marking the scripts as an error mid-process. To extend the maximum execution time, edit the .htaccess file, install the Google Pagespeed Insights plugin, or change the PHP configuration using your cPanel.
The default value for script execution time is 30 seconds. Increase the value of max_execution_time to 60 and save the changes. You can also increase the value further to 120-180 seconds if the problem persists.
Note: See the four different types of errors in PHP code.
Configure DNS Settings
DNS issues can cause a 504 error both on the client and server side. Server-side issues occur on websites with unresolved IP addresses, especially if your website was recently moved to a different domain or server and the change still needs to take effect globally. It takes between 28 and 48 hours to complete DNS propagation.
Client-side DNS issues can be resolved by flushing the DNS cache from your operating system. Flushing the cache eliminates corrupted and outdated cache files from the system, which could be the cause of the 504 error.
Check the Error Log
Inside the directory, locate the debug.log file. The file contains all WordPress errors, warnings, and notices that were logged.
Outdated, incompatible, or incorrectly configured third-party WordPress plugins can cause a 504 error. For example, some caching plugins send requests to the server, which increases PHP workers' workload, and in turn, it can trigger the 504 error.
Temporarily disable all plugins to check if the error persists and if the cause is a faulty plugin. Using a File Manager or FTP Client, navigate to the /wp-content/ directory and rename the plugins directory to disable all the WordPress plugins.
If disabling the plugins resolves the 504 error, find out which plugin is causing the 504 error. Restore the directory to its original name and disable the plugins one by one to pinpoint the source of the problem.
If the 504 error clearly states that there is an issue with Cloudflare, you have found the cause. Check the Cloudflare system status to determine whether the company announced network issues.
If Cloudflare is the cause of the issue, the fastest way to solve the problem is to contact them and request support. Another solution is to disable the CDN and wait until the DNS is fully propagated.
This article has explained what the 504 Gateway Timeout error means and its variations and provided some troubleshooting steps for website visitors and website owners.