How to fix 504 gateway timeout error in WordPress

504 gateway timeout is one of the HTTP status codes that appears when a server fails to get a timely response from another server.

Like the or , it is one of the most common server errors encountered by users and website owners alike.

Every second of inactivity can hurt your WordPress site’s performance in search engines. Therefore, as a website owner, you should fix this problem as soon as possible.

Debugging the 504 gateway time-out error can be challenging due to the large number of possible reasons. In most cases, it can be resolved by refreshing the web page.

In this article, we will go over the possible causes of the 504 gateway timeout error. We’ve included tips to help you fix the problem and get your site up and running in no time.

What is Error 504 Gateway Timeout?

The 504 gateway timeout error occurs when a server does not receive a timely response from another server acting as a gateway or proxy. As a result, the proxy server is unable to retrieve the required content from the database, which prevents the web page from loading its content.

Variations and Causes of the 504 Bad Gateway Timeout Error

When you encounter the 504 Bad Gateway error, it will typically look something like this:

This HTTP error can also appear in different forms and with various error messages on different browsers, servers and operating systems. These are the most common:

  • 504 Gateway Timeout nginx
  • Gateway Timeout Error
  • Gateway Timeout (504)
  • HTTP Error 504
  • Error 504
  • 504 error
  • 504 Gateway Timeout – The server didn’t respond in time
  • This page isn’t working. Domain took too long to respond
  • HTTP Error 504 – Gateway Timeout
  • 504 Status Code
  • 504 Error Code

Determining the causes is the first step to solve the error 504 Gateway Timeout. Here are several issues that can cause this error:

  • firewall issues. Some firewalls’ DDoS protection and mitigation systems can block requests from a specific Internet service provider or content delivery network such as . A faulty firewall configuration can also be the problem.
  • unresolved domain. This occurs when a domain does not resolve to a correct IP address. This issue can occur when a website has recently been moved to a different IP address or nameserver.
  • connectivity issues. If the 504 Gateway Timeout error appears on multiple browsers, devices, or websites, your network device may be experiencing temporary connection issues.
  • Web server overload. A web server with few resources can become overloaded and therefore respond to browser requests slowly, causing the other server to time out.
  • Limited PHP Workers. These components handle requests each time a visitor performs an action on a WordPress website. Without enough PHP workers, your website may fail to process multiple requests.
  • Problems with the domain name system (DNS). These include incorrect DNS settings and an outdated or corrupt DNS cache.
See also  VPS - Virtual Server In Spain |

How to fix the 504 Gateway Timeout error

In most cases, 504 errors are caused on the server side. However, they can also appear due to problems or misconfiguration on the client side.

Let’s go through the basic steps to fix the issue with both options in mind. Most of the solutions apply to any website, but some are specific to WordPress.

1. Refresh the page

This tip may seem simple, but it is one of the most common solutions to resolve the 504 gateway timeout error. It is possible that the server is receiving more requests than usual, so it is worth trying to refresh the page.

The easiest way to do this is to click the button To update next to the browser’s address bar or press F5. You can also press Ctrl+F5 to clear the browser cache and force the page to refresh.

While you wait for the page to refresh, check to see if the website is down. This will confirm if the problem is related to your local network.

2. Review order utilization

Each hosting plan allocates a certain amount of resources for optimal website performance. users may have assigned by accessing the menu of Order Utilization in the hPanel.

If your WordPress site has reached the limits of the hosting plan, users will see a server error message. If this is the case, contact your hosting provider to upgrade to a plan with more resources that better suits your site’s needs.

Another possible solution to this problem is to increase PHP’s maximum execution time limit. Server timeouts can occur when PHP scripts take longer to complete than the defined duration.

will help prevent scripts from being marked as an error mid-process. To do this, manually edit the , install the plugin or change the PHP settings through the control panel of your hosting account.

These are the steps to increase the value max-execution-time of WordPress through the hPanel:

  1. go to PHP configuration in the section Advanced of the hPanel.
  2. Click on the tab PHP Options and scroll down until you locate the field maxExecutionTime.
  3. The default value is 30 seconds. increase it to 60 and click Save. If that doesn’t solve the problem, increase the value to 120-180 seconds.
See also  Get a free SSL Certificate and Secure Your Website |

Do not set the maximum execution time value to 0, as this will cause PHP scripts to run for an infinite period and consume your server resources.

3. Try a different browser

If refreshing the page and increasing the maximum execution time limit for PHP scripts did not resolve the 504 gateway timeout error, the problem could be browser related.

Try loading the WordPress site in another browser and using incognito mode to verify that this is not a server-side error. before reloading the page will also increase load time and reduce the likelihood of server timeouts.

4. Refresh DNS cache

Problems can originate from both the server and client side. Server-side ones usually occur on websites with unresolved IP addresses, while client-side ones are caused by an outdated or corrupt DNS cache.

If the WordPress site was recently moved to a different domain or server, the change may not have finished propagating globally. DNS propagation takes 24-48 hours to complete, so use a to check if the process is complete.

To fix client-side DNS issues, try . Like browsers, your operating system maintains a local cache. Flushing DNS will remove corrupted and outdated files from the cache that may be causing errors.

The way to do it differs depending on your operating system. For example, here are the steps to flush the DNS cache in Microsoft Windows:

  1. press the keys Windows+R at the same time and write cmd to open the command line.
  2. Write ipconfig /flushdns and press enter to clear the DNS cache files and reset the DNS resolver cache.
  3. A confirmation message will appear if the process is successful.

Flushing the DNS cache is especially beneficial for Google Chrome users, as the browser stores a cache independent of the operating system.

Temporarily changing your DNS server to a public one is a great way to rule out the possibility of a DNS-related problem. Some of the more popular public DNS servers are , and .

5. Test on different devices

Try loading the web page on a different computer, network connection, or mobile phone. You can also try restarting network devices to see if it’s a hardware or internet connection issue.

If the 504 error persists on multiple devices, it’s likely a server-side issue.

6. Check the error log

The 504 gateway timeout error can also be caused by recent website changes or updates. The quickest way to find out is to check the error log for clues.

users can enable the PHP error logging feature in hPanel. This is how you do it:

  1. go to PHP configuration in the section Advanced of the hPanel.
  2. Access the tab PHP Options and check the box logErrors.
  3. Scroll to the bottom and tap Save.
See also  What is shared hosting and how does it work?

If your hosting provider does not offer PHP error logging by default, you can enable it by adding the following lines to the file:

define( ‘WP_DEBUG’, true ); define( ‘WP_DEBUG_LOG’, true ); define( ‘WP_DEBUG_DISPLAY’, false );

when setting WP_DEBUG_LOG set to true any errors in the file will be documented wp-content/debug.log. In the meantime, WP_DEBUG_DISPLAY dictates whether or not debugging messages will appear on HTML pages.

7. Check plugins

In rare cases, a may be causing the 504 error. Some plugins, especially those related to caching, send requests to the server, thus increasing the load on PHP workers, which could trigger the problem.

Outdated or incompatible plugins can also cause problems. Temporarily disabling all of them will help you check for a faulty plugin.

go to the directory wp-content and rename the folder from plugin. This will disable all WordPress plugins. You can do it through the File Manager of your hosting account or an FTP client like .

If your site works fine when all plugins are disabled, the next thing to do is to locate which one is causing the error. Restores the original name of the directory plugin and disable the plugins one by one to locate the source of the problem.

8. Check CDNs

If you use a (CDN) so that the contents are delivered faster, it is worth checking if it works correctly.

One of the most used CDN solutions is CloudFlare, which also acts as a DDoS mitigation service. When using it, you may come across two versions of the 504 error.

If the error message mentions CloudFlare, then the problem originates there. You can check the to see if the company is aware of any network issues.

In this case, contacting CloudFlare support is the fastest way to resolve the issue. Otherwise, disable the CDN completely and wait until the DNS is fully propagated.

This version of the 504 error page indicates that the problem is coming from the web host, which you will need to contact for help.

9. Adjust server settings

The…

Loading Facebook Comments ...
Loading Disqus Comments ...