How to Fix the 504 Gateway Timeout Error Code (10 Easy Fixes)

Giving your audience what they want is one of the worst things a brand can do. When visitors to your website look for advice or information to help them do their jobs better, they may become irritated and lose trust in your brand, irreversibly hurting your reputation.

504 Gateway Timeout Errors are, unfortunately, a bit mysterious. They tell you what occurred on your website, but they don’t tell you why, making it difficult to pinpoint the cause and, ultimately, fix the problem.

What is meant by the 504 Gateway Timeout Error?

When your web server attempted to load one of your web pages, it received a 504 Gateway Timeout Error, which means it didn’t obtain a timely response from another server upstream.

Simply put, your web servers aren’t able to communicate with one another quickly enough. Because a 504 Gateway Timeout Error is so broad, it can’t pinpoint the particular source of the problem.

When this happens, your website’s visitors will be directed to an error page.

504 error

Here are a few common causes of it:

  • Because a server timeout causes the 504 error, the issue is most likely not with the client’s device or internet connection. This includes your device as well as your internet connection.
  • A 504 Gateway Timeout error signals that the web server is “timing out” after waiting too long for a response from another server. This timeout could be caused by several factors, including the other server not functioning correctly, being overloaded, or unavailable.
  • It is not always necessary for the other server to be external (e.g. CDN, API gateway). It could also be a server-like entity that runs alongside the central web server (e.g. reverse proxy server, database server).

Fix 1: Try to reload the webpage.

When you get a 504 Gateway Timeout problem, one of the first things you may do is wait a few minutes and then try reloading the page.

In most browsers, pressing the F5 keyboard shortcut will refresh/reload the webpage. Instead of pressing CTRL+F5, you can use the CTRL+F5 shortcut combo to clear the page’s browser cache before filling.

While you’re at it, try loading the site in a different browser to see if that’s the problem. Because most 504 failures are caused by temporarily overloaded servers, using this method should restore your site’s functionality.

Fix 2: Check if the website is down for everyone or just for you.

If waiting and reloading the site does not resolve the 504 problems, you can see if it is down for everyone or just you. You may use our online tool to check the status of the website.

To see if the website is down for everyone or just you, type the website URL and then click “test.” If a page is unavailable, you must wait for it to be restored from the server or its developers.

web up or down

Fix 3: Restarting the device.

So you’ve utilised a site-checking tool and concluded that the site is just unavailable to you. However, you’ve also tried a different browser and are having the same issue. This indicates that the issue is most likely on your end and not with your browser.

Your computer or networking equipment is likely having some unusual, transient troubles (Wi-Fi, router, modem, etc.). A simple restart of your computer and networking equipment may be all that is required to resolve the issue.

Fix 4: Clearing the browsing history and data.

Step 1: Click on the three vertical dots from the browser’s top right corner and select the “Settings” option from the opened menu.

Step 2: Select the “Privacy and Settings” option and then go to the option stating “Clear Browsing Data”.

3: tick all three check boxes available in the opened section, select the time as “All time”, and click on the “Clear data” button.

clear browsing data

Fix 5: Flushing the DNS

A 504 gateway timeout might occur due to a misconfigured or outdated DNS cache, but clearing it is simple. Depending on your operating system, you’ll have to do it differently. To flush DNS on Windows, follow these steps:

Step 1: Press the Windows+R keys simultaneously, or right-click the Start menu and select Run. To open the Windows command prompt terminal, type cmd. Suppose you don’t have administrator access yet; press Ctrl+Shift+Enter to run the cmd command.

Step 2: On the command prompt, type ipconfig /flushdns and hit enter. This command clears your computer’s DNS cache files and resets the DNS resolver cache.

Step 3: You’ll receive a confirmation message on your command prompt if the operation was successful.

flush dns

Fix 6: Checking the plugins.

It’s a good idea to browse through your website’s plugins and extensions while troubleshooting a 504 gateway timeout problem. Plugins linked to caching in WordPress can be the source of the problem.

Plugins that are out of date or incompatible can also cause issues. As a result, momentarily silencing all of them will allow you to know if you’re digging in the appropriate spot. To do it in a matter of seconds, follow these steps:

Step 1: From your WordPress Dashboard, go to the Plugins area.

Step 2: By clicking on the Plugins, you may turn them off.

504 plugin

Fix 7: Disabling the proxy settings.

Proxy servers assist ensure privacy by acting as a middleman between web servers and browsers. These servers allow you to go online while keeping your IP address private, as well as filtering traffic between servers.

However, the web server may reject the proxy based on the IP address, resulting in a 504 gateway timeout error. It’s also possible that incorrect proxy settings cause this. As a result, you must temporarily disable the proxy server to resolve the issue. Here’s how to do it yourself:

Step 1: Select Settings from the three dots in the upper right corner of the browser.

Step 2: To open proxy settings, go to Advanced Settings and then Open Proxy Settings. Your device’s settings will be redirected to you.

Step 3: Toggle the Use a proxy server option to Off now.

504 porxy

Return to the website and see if the error still exists.

Fix 8: Checking the Firewall settings.

If you’re using a content delivery network to serve your site, your WordPress host server may detect big requests from the CDN, resulting in a 504 gateway timeout problem.

You’ll need to whitelist all IP addresses from the CDN your site uses to fix this. In the .htaccess file on your host server, you can whitelist an IP address. Follow the steps below to accomplish this:

Step 1: Connect your site to an FTP client and then go to the root directory to store your website’s files.

Step 2: To download a backup of the .htaccess file, double-click it.

Step 3: After that, right-click the .htaccess file and choose View/Edit from the context menu.

504 htaccess file

Step 4: Now, paste the code snippet below into the file.

Require all granted

Require ip 127.0.0.1

Substitute the IP address you want to whitelist for 127.0.0.1.

To whitelist several IP addresses, start a new line and type the command Require IP 127.0.0.1, replacing 127.0.0.1 with the correct IP address. Rep till all IPs have been whitelisted.

Fix 9: Checking the error logs.

When troubleshooting and debugging 504 issues on your WordPress site, viewing error logs can be highly beneficial. This might assist you in swiftly identifying a problem with your website.

If your server doesn’t provide a logging tool, you can use the following code in your wp-config.php file to enable WordPress debug mode:

504 wp config

define( ‘WP_DEBUG’, true );

define( ‘WP_DEBUG_LOG’, true );

define( ‘WP_DEBUG_DISPLAY’, false );

The WP_DEBUG constant controls whether the WordPress debug mode is enabled or disabled. In addition, it contains two partner constants that can be used to increase its capabilities. Finally, all errors are stored to a debug.log file in the /wp-content/ directory when the WP_DEBUG_LOG constant is set.

debug file

Fix 10: Contacting customer support.

If the 504 gateway timeout error remains after trying all of the remedies mentioned above, you should contact your web hosting support team. To expedite the process, try to detail the actions you took to fix the problem and offer as much information as possible.

Conclusion

As you can see, there are a variety of approaches to resolving the HTTP 504 gateway timeout problem on a WordPress site. Typically, this is a server issue, and in this instance, you must contact your hosting provider to resolve the issue. However, it’s vital to keep in mind that they can also be triggered by third-party plugins or a PHP worker queue/backlog overflow.