How To Fix The Error 504 Gateway Timeout On A Website? (Complete Guide)

How To Fix The Error 504 Gateway Timeout On A Website? (Complete Guide)

userPosted by Mason Lava

The error 504 gateway timeout is a common error faced by website owners and visitors. However, for the website owner with a WordPress website or an eCommerce website, knowing how to fix it is crucial. The competitor site may take their customer away in a delay of a few seconds.

So, in this guide, you will learn what is 504 gateway timeout, how it occurs, its effect on SEO and solution in a detailed manner.

 

What Is 504 Gateway Timeout?

All error codes starting with 5xx are the errors from the server-side.  Here, the 504 gateway timeout error is in the HTTP status code. It refers to a time delay in response from one server to another server (gateway or proxy).

 

Why Does The 504 Gateway Timeout Error Appear?

To understand how the gateway timeout error appears, you need to go through its working first. You need to understand how a website responds when you ask for it.

  • When you visit a URL on your browser, it sends a request back to the hosted server.
  • Now, the web server reads your request and processes it by sending back the resource to you along with an HTTP header.
  • Here, the HTTP header comes with several status codes with an explanation of the issue.

However, not all HTTP codes are bad for instance, status code 200 indicates that everything is alright.

 

What Causes The HTTP Error 504?

One of the main causes is the delay in response from the gateway. Besides that, there are other reasons that cause the 504 gateway timeout error to occur.

  • The severe issue on both or one side:  Well, it should be clear that if there is a severe issue then it may not necessarily be from the client’s side. It can also be from your side. For instance, a slow, severe, or poor internet connection may lead to the error.
  • Firewall Issue: sometimes the firewall on your server may lead to an error. If there exists an error or is misconfigured or rules blocking, then it may show an error.
  • PHP Workers:  when the server is slow and pending requests are created, old requests get deleted. And, it shows an error 504.

The error can appear in various forms and it’s because different operating systems display different messages. So, you don’t get confused, we have listed the possible forms of 504 error.

  • HTTP Error 504
  • 504 Gateway Timeout – the server didn’t respond in time.
  • 504 Gateway Timeout NGINX
  • NGINX 504 Gateway Timeout
  • Gateway Timeout Error
  • Error 504
  • HTTP Error 504 — Gateway Timeout
  • HTTP 504
  • 504 Error
  • Gateway Timeout (504)
  • This page is not working — Domain took too long to respond
  • 504 Gateway Time-out — The server didn’t respond in time
  • A blank white screen

All of the error messages mentioned above may be worded differently but indicate the same problem.

Webmasters and web servers have the option to customize the appearance of the error 504. Some of the websites become creative to quell the visitor’s disappointment.

 

 Impact of 504 Gateway Error On Seo

Although, it is a common error yet the impact can be detrimental to a website. It can have a grave impact on search engine optimization. That is why search engines like Google and Firefox take this error seriously and take rapid action.

Let’s understand here.

For an error 503, google understands that the service is unavailable temporarily. Hence, it will try again to crawl the page later. But in the case of 504, the concept is very different.

In the case of a 504 gateway error, it may not be a temporary error. It can linger on for a long time which may affect a website’s growth.

For any website that is unavailable or has a 504 error for a long time, say 6+ hrs then, Google will take it seriously. You need to fix the gateway timeout error, as soon as possible or the web pages may get de-indexed from the search engine results.

Now, let’s move to the next section where we will discuss the possible fixes for the gateway error.

 

How To Troubleshoot And Fix The Gateway Error 504?

No matter how cool the webmasters make the gateway error 504 appear, it is still annoying. After all,  you are visiting the website for some reason and not to meet some cartoon character.

So, let’s discuss the fixes in the simplest and most effective manner.

 

1. Restart Your Device And Network

Sometimes, the network connection is the real culprit behind the timeout gateway error. Hence, you can try restarting your device and the network connection as well.

  • First, restart your system.
  • Meanwhile, on its restarting, turn off and again on the network connection (router/wi-fi).
  • Now, connect the network with your system and try again.

If this method is unable to resolve your issue, move to the next solution.

 

 2. Refresh or Reload the Webpage

More often, a page after refreshing or reloading gets back on the severe. Likewise, without getting panicked, you should try the method first.

  • You can press the F5 key to refresh the page.
  • Or, just right-click on the screen and select reload. Wait while it reloads.
  • You can also press the keys Ctrl + F5, to clear the browser’s cache and then try to reload it.

 

ProTips and tools

You can check if the site is down only at your end or is down for others also.

For that, copy-paste the link:

  • https://downforeveryoneorjustme.com/ or
  • https://www.isitdownrightnow.com/, and enter the domain address or URL you wish to check for.

 

 3. Try Accessing The Website On A Different Browser

Now that you have tested the visibility of a website online for others, try this method.

Try accessing the website in Incognito mode. Or, use a browser other than the one causing trouble for you. It can help you determine if the problem is with the browser or website.

 

4. Try Accessing The Website On Different Devices

Like the previous method, try accessing the same website on different devices with different networks. This step will help you figure out where the problem is- on the server-side or it is local.

 

 5. Disable The Proxy

If you are using a proxy network, minor but the chance is that it may cause the 504 gateway timeout.

A proxy server acts between you and the client-server. It creates a secure network for your IP address by hiding the reallocation.

Although the possibility is almost null (especially on the client-side) yet you can try to disable it. Incorrect proxy server settings may be the reason. Once disable it and try reloading the page.

 

6. Check DNS Records Propagation

Often, the HTTP error 504 is caused by the DNS server. The problem can have roofing from any of the slides, the severe side or the client-side. Let’s understand each side’s problem.

 

  • Server-side issue

The main reason for the gateway error can be due to a fully qualified domain name (FQDN). That is FQDN does not resolve the correct IP address or the DNS server is being unresponsive.

The possible activity of its unresponsiveness is the changed host server. Suppose, if you have just shifted your current WordPress site to another hosting server, you need to wait. Usually, one has to wait up to 24 hours until the DNS records propagate fully.

 

  • Client-side issue

In this case, you have to clear or flush the DNS cache. It’s nothing different from clearing the caches in a browser. The only difference is the tag line that is “flushing the DNS cache” here.

 

If you have windows:

 

you can clear the caches directly from the command prompt.

  • Open the command prompt.
  • Type “ipconfig/flushdns”.
  • A message will prompt “Successfully flushed the DNS resolve Cache.”

 

On Mac/Linux:

  • Open the terminal.
  • Run the command “sudo killall -HUP mDNSResponder.”
  • No message will appear on the screen when the process is finished.

You can only change the DNS server temporarily as the DNS server is provided by your ISP. further you can also try public severe to change DNS temporarily; Google’s public DNS, Quad9 DNS, and Cisco OpenDNS.

 

7. Disable The CDN Temporarily

Another reason that the HTTP error 504 occurs is due to the content delivery network. It’s because when a site’s origin server is not reachable, most CDN’s will try to provide full web pages stored in the cache.

Hence, in the case of third-party CDN, you can disable it temporarily. For instance, if you are accessing a free CDN enabler WordPress plugin to link your site’s asset to CDN URL, disable it temporarily.

Further, the same can be performed in other plugins like WP Rocket, Breeze, or W3 Total Cache. Or, if you don’t have site plugin access, then rename the plugin folder.

 

Using Cloudflare:

 

If you are using Cloudflare then you can’t actually lame it. Instead, you need to identify the error type first.

Case 1: If you see a page almost black with a few words “504 Gateway Timeout”, the issue is from Cloudflare’s side. Contact their customer support or check their status page. However, in such a case, the engineers are aware of the issue and often work on it.

Case 2: If the page reflects proper working from the Cloudflare side then the issue is with the hosting side. In this case, move to the recommendations mentioned below.

 

8.  Fix The Issue With Your Hosting Provider

The major reason for the occurrence of gateway error 504 is related to the server. Though several WordPress websites are hosted on the Nginx or Apache web servers, the issue came up. While Nginx or apache is waiting for a response from another server and times out, the issue occurs.

If you notice, the 504 error is very popular on eCommerce sites and online stores. It’s because the visitors are in high numbers however, the latter may have installed eCommerce plugins like Woocomerce.

Such sites witness several non-cache requests which further can overload the server. This is a common issue that may appear even on a simple website like blogs.

For that, many hostings recommended upgrading to a more expensive tariff plan.  A plan that caters to the need, is a good option. Yet, it is not necessary for everyone to buy an expensive tariff plan.

Note that many hosting offer resources dedicated to each severe. That means each site is hosted in its isolated container. Here, resources are kept confidential and have the potential to run it. Nonetheless, there are various shared WordPress hosting providers, which do not have this feature. Hence, any neighboring site with high traffic will show a gateway timeout error.

To escape such errors in the future, you can take the help of a tool ‘statuscake.com’.

  • It tracks the server and reports any problem immediately.
  • Sends an HTTP HEAD request to the specified URL periodically.
  • It will inform you via email if your site is out of service recording the time also

Such a service is useful in the case of virtual hosting. Where it will cite the reason and time of the site of not working and suggest too you move on to dedicated hosting.

 

 9. Clean Site- Spams, Bots & Protect From DDoS Attacks

If none of the above is the issue then malicious attacks or spamming is what is causing the error. It so happens that your site has been DDoS attacked or spammed by bots. This, as result, can lead to uncache requests and eventually overload the server. Which then will cause an error 504.

 

You can request your hosting provider to send the analytics and learn from it.

  • The first report would be Top-end customer IP addresses. You can get an idea of who generates the large traffic or was attacked by the bots.
  • The second report to look after is the requests and bots. Here, you can calculate the number of visitors and bots. Though, not all bots are bad. Because some bots help in indexing the content on the search engines.
  • cache analysis:  With this report, you can find the missing requests and the top locations of your site.

Note that, the number of requests matters for any site to perform better and gain stability. Although, it is not always possible. Because some resources like Woocommecere generate a number of uncached requests.

With these reports, you can also identify which traffic or IP address are to be blocked. For that, you can use WordPress security plugins.

However, the same does not apply to all hosting servers. Because many don’t allow as the plugins can:

  • Influence the performance (mostly after scanning the severe).
  • Using the load balancer from Google cloud Platform that may not comply with IP blocking features.

Nonetheless, blocking unwanted traffic or Ip addresses may not always help. When the attack/spam is blocked in one area, it finds another zone by changing its IP address or proxy. Hence, to escape the issue in the long term, we recommend you install a robust security solution such as Cloudflare or Sucuri.

 

10. Check Your Plugins And Themes

Well, many users believe that plugins and themes do not clog the server with gateway error 504. In many cases, it goes right as worded.

However, the situation keeps changing and many users have the opposite experience. According to them, a slow non-cached plugin request may also cause delays. Why? Well, it’s because it would need to use more PHP workers as mentioned above.

What happens here is that your old requests are deleted when you reach the limit of request. Apparently, an error 504 appears usually confused with error 502. The error 502 refers to time out of 60 seconds.

 

To fix the issue:

1. Deactivate all your plugins with the admin panel: you will not lose any data. So to disable the plugins login to the admin panel >> Plugin section >> select Deactivate.

  • If it fixes the issue, the next move is to find the issue with each plugin. That is activate all plugins one by one and restart the site and identify which one is the source of error.
  • Once identified, contact the plugin developer or raise a ticket in the WordPress repository.

 

2. Deactivate all your plugins without an admin panel: in case you don’t have admin access, use the FTP client to connect to your server.

  • Rename the plugin folder.
  • Test the site by reloading it.
  • If it works, test each plugin separately and rename the folder the same as the previous one.
  • And, rename each plugin folder inside the main folder and test.

Before you apply this method, ensure you have the latest version of plugins, themes, and the WordPress kernel.

 

11. Check Error Logs

Error logs can help you in troubleshooting and debugging the error 504 on your WordPress website. It can help in filtering out the issues on your site rapidly, especially when born out of the demanding plugin.

You can see the error logs of the hosting dashboard. However, if it doesn’t provide the data, use the following codes:

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

To find the logs, you can visit :

  • The /wp-content folder
  • Apache or Nginx logs

 

12. Check Nginx Options

This method is useful for those who maintain their server and WordPress website. Tweak the settings to eliminate the gateway error 504.

Case 1: using Nginx with FastCGI (php-fpm)

  • Make changes to the PHP-FPM file.
  • Head to /etc/php5/fpm/pool.d/www.conf

Set directives as mentioned below:

  1. To modify the php.ini file,usually located at /etc/php.ini
  • request_terminate_timeout = 300
  1. Find max_execution_time directive, or create a directive
  • max_execution_time = 300
  1. modify the nginx.conf file. dd, following to your Nginx virtual host configuration:
  • Code as:

Location ~ .php

${

Fastcgi_read_timeout 300;

}

  1. Restart Nginx and PHP-FPM.
  • service nginx reload
  • service php5-fpm reload

Further, if you’re using Nginx as a server for Apache then you may need to tweak the additional settings to eliminate the gateway error 504.

  1. Add the following to your nginx.conf file:

proxy_connect_timeout 600;

proxy_send_timeout 600;

proxy_read_timeout 600;

send_timeout 600;

  1. Restart Nginx

service nginx reload;

 

Conclusion

If the error 504 gateway timeout is repeating after performing all methods above, contact the hosting technical support. Typically, it’s an issue related to the server, but it can also be caused by third-party plugins or the queue/backlog overflow of your PHP worker. If you are still confused or have more queries, you contact our WordPress Support experts.

Tagged with:
  • On Time Delivery

  • 50

    Discount

  • 24×7 WordPress Support

  • Cost Effective Services

  • Skills Wordpress Developers

  • 100% Satisfaction