How to Fix a 504 Gateway Timeout Error on Your WordPress Site

How to Fix 403 Access Denied Error in WordPress

Error messages are unpleasant sights – everybody knows that. Regardless of whether you’re just casually browsing the internet, or running a site from which you draw your basic income, you definitely don’t want to encounter one and compromise your online experience or your online business. 

But error messages do happen, they happen frequently, and there’s plenty of them! From the 504 gateway timeout error we’re going to talk about today to the 502 bad gateway error, the white screen of death and the error establishing database connection. 

The good news is that all of these error messages and the reasons behind them are fixable. If you act fast and follow the steps we’ve provided here, you’ll have your site up and running in no time and you won’t have to worry about losing any customers or elevating visitor’s bounce rates. 

How to Fix 403 Access Denied Error in WordPress

What is a 504 Gateway Timeout Error?

Before we talk about the ways to fix this error, first we’d like to clarify how it actually emerges. 

In short, 504 gateway timeout error means that there’s something wrong with the server where the site that you want to visit/access is being hosted on. It means that they haven’t given your host server a response in due time. 

That’s why you’ll often see this phrase next to the 504 HTTP status code: The server, acting as a gateway, timed out waiting for another server to respond.

There are plenty of different 500 error codes (500, 501, 502, 503 504, 520, and others) and they all point to different server issues. They usually tell you that the request you’ve made has been accepted, but that the server on the other side didn’t manage to fulfill the request. 

504 Gateway Timeout Error Variations

There are also variations of the 504 gateway timeout error itself. This usually has to do with different operating systems, different servers on hosting platforms, as well as different web browsers. But, it’s important to remember that ultimately they point to the same thing. Here you can see the variations of the 504 gateway timeout error. 

  • 504 Gateway Timeout
  • Error 504
  • Gateway Timeout Error
  • 504 Gateway Timeout NGINX
  • NGINX 504 Gateway Timeout
  • Blank white screen
  • 504 Error
  • HTTP Error 504
  • HTTP 504
  • HTTP Error 504 – Gateway Timeout
  • 504 Gateway Time-out – The server didn’t respond in time
  • Gateway Timeout (504)
  • This page isn’t working – Domain took too long to respond

Some company websites, however, have custom-made 504 error messages. 

504 Errors and SEO

You might already know this, but 504 errors and the like can definitely have a negative SEO impact. Having your site down for more than just a couple of minutes is something no online business wants to go through, especially if it’s down for more than an hour. This is because a site that’s been down for over 6 hours will have trouble with Google’s crawlers and might lose Google rankings. So if you encounter this error on your site, you should get down to fixing it as soon as possible.

How to Fix the 504 Gateway Timeout Error

And finally we come to the part you’ve been waiting for – how to fix the 504 error! 

We know error messages can be really frustrating most of the time, but in a lot of cases they’re nothing to worry about and can be easily fixed. The 504 gateway timeout error message is one of them – it usually has to do with server issues where the site is being hosted or network connectivity problems. But, sometimes it’s also an issue from the client-side, and can show up as a result of a third party plugin. We’ll cover all of them in here and tell you how to fix them. 

So, read on and find out how to fix the 504 gateway timeout error to get your site online again in a matter of minutes!

  1. Reload the Website 

This is the simplest and easiest thing you need to do and it just takes a couple of minutes of your time. Sometimes it happens that the host is overloaded with requests which makes the site temporarily unavailable. So the first thing you need to do is reload the site you’ve requested after a couple of minutes from your last unsuccessful attempt. 

You could also try a different browser if you don’t see any results, just to be sure. 

Also, make sure to check if the site is generally down or if the problem is from your side. You can visit this site www.downforeveryoneorjustme.com and easily check on whose side lies the 504 problem. 

  1. Disable the Proxy Settings

You may see this error if you’re using a proxy service, but it’s kinda rare. In any event, you may have some settings set and not even know it, so you’d want to check them out if you keep encountering the 504 error. 

  1. Issue with the DNS Service

The 504 gateway timeout error also shows up as a result of an issue with the DNS service you have. These can both be on the server side and the client side. 

Server Side DNS Issue 

Server-side DNS issue means that the domain isn’t resolving to the right IP. This can sometimes happen if you’ve recently migrated your site to a new hosting provider. That’s why it’s so important, once you migrate your site, to wait for things to propagate fully, something that might take even 24 hours. All of this is dependent on the TTL value of your DNS records. When you want to check if your DNS has fully propagated around the world, you can use the free tool DNSMap, for example. 

Client-Side DNS Issue 

If the issue is with the client-side DNS, then you should attempt to flush your local DNS cache, which is not unlike cleaning your browser cache. 

You can open the Windows Command Prompt and import the following lines: 

ipconfig /flushdns

If it works, you will be able to see this: “Successfully flushed the DNS resolver Cache”.

If you’re a macOS user, in the terminal, you can put the following:

dscacheutil -flushcache

You can also temporarily change your client-side DNS servers. DNS servers are assigned automatically by your ISP, aka by default. You could, however, try and change them temporarily to a public DNS server, like the one Google has. 

  1. Disable CDN Temporarily 

The 504 error can also signal a problem with your CDN (content delivery network). If you use a 3rd party CDN, then you can easily troubleshoot it by disabling it temporarily. A good way to do this is through the CDN enabler plugin. If you have this plugin, you can just deactivate it and see whether your site works again. 

If you don’t have access to the dashboard of your site, you can log in through the SFTP and rename the folder of the plugin into something like ‘cdn-enabler_old’. This action will disable the CDN connection temporarily and will allow you to see whether your CDN settings are causing the 504 error. 

This type of issue can sometimes happen with proxy services such as Sucuri and Cloudflare because they have additional in-between firewalls. In fact, the majority of them cache the 500 status codes if it happens that they’re being returned by your hosting server. If you notice this happening, you should contact the services – there’s really no quick way to disable these types of CDN since they’re a full proxy service. 

  1. Issues With the Server (In Which Case You Should Contact Your Host)

As we mentioned earlier, server issues are one of the most common reasons behind the 504 gateway timeout error on WordPress. It means that the server has waited for a response from the other side but hasn’t received it in due time. 

These types of errors show up more often on eCommerce sites, such as WooCommerce – sites that are high in traffic and have plenty of uncachable requests. These can often overload the server which results with the 504 error message. 

Be that as it may, in the end, all types of sites are susceptible to these types of errors. Lots of hosts will just tell their clients that they need to upgrade their plan and easily fix the issue. This may help with eliminating the 504 issue, but it’s not always a necessity. Look at our list of the best web hosting providers currently on the internet. 

Other reasons why you may be encountering server issues which are causing the 504 error

  • Slow server – the server of your WordPress site can be too slow to respond to the request which could result in the 504 gateway error.
  • Deficit of PHP workers – PHP workers are necessary to execute your site’s code. If you have a more demanding site, it means that all the PHP workers are busy and they start building a queue. And if the queue and backlog get full, the old requests are becoming neglected. In this case you can contact your host and ask them whether they can raise the number of PHP workers for your site. This will enable your site to execute multiple requests at the same time. 
  • Issues with firewall – sometimes your server’s firewall might contain errors and can be badly configured. It can also have certain rules and configurations that prevent it from establishing a proper connection. 
  • Network connectivity – if there are any issues between the proxy server and the web server with the network connections, it could also be the reason behind delayed response over HTTP requests. What’s more, there can also be network connectivity issues with a load balancer, if you’re using one.
  • HTTP timeouts – these can occur when your browser’s and web server’s connection is held open for a long time. This usually happens when WordPress imports are running. You can switch to a faster internet connection as a way to resolve this issue. You can also use a tool that supports WP-CLI – one such tool is the WordPress Importer plugin. You can bypass the HTTP connection entirely by running the import directly on the server.

NOTE: Sometimes 504 errors can be mixed up with 503 service unavailable errors, as well as 502 bad gateway errors. Keep in mind that they’re all different, however. 

If you want to have more control over these errors happening on your site, you can use the updown.io tool and keep an eye on them, as well as know when they occur. This tool sends periodic HTTP HEAD requests to the URL you enter (you can use your site’s URL). The frequencies available are: 

  • 15 seconds
  • 30 seconds
  • 1 minute
  • 2 minutes
  • 5 minutes
  • 10 minutes

It will also send you an email notification whenever your site goes down. 

Lots of website owners who are using a shared host find this especially useful, since the servers are often overcrowded, which is why it’s a good idea to use a managed hosting instead. 

  1. Spam, Bots, or DDoS Attack

Sometimes your site can be attacked by DDoS, bots, or spams. All of these attacks can burden and overwhelm the server, and they can cause uncached requests which ultimately leads to the 504 gateway timeout error. 

Your server analytics are a good place to start – you can check to see whether there are any suspicious patterns, or ask your hosting provider for some more data. One of the first reports you should look at is the top clients IPs. This can be informative especially if your site is all of a sudden generating lots of bandwidth or is being hit by bots.  

The second report you should look at is the cache analysis. This will give you info on the top locations on your site, and how many requests are bypassing and missin the cache. You’d definitely want more requests to be cached, in fact, as many as possible, mainly for stability and performance reasons. Unfortunately, this isn’t always possible, especially for WooCommerce sites who have lots of uncachable requests.

If you notice any suspicious traffic or IPs that you think should be prevented from accessing your site and blocked, you should definitely look into WordPress security plugins. 

  1. Check Your Plugins and Themes

While this is not the most common of reasons for the 504 error message, it can still be the main culprit. 

Sometimes plugins cause delays with slow uncached requests. This is because it ties up more of the PHP workers of your site, and once you’ve reached the limit, the queue then starts to push the older requests and all of this might result in a 504 error message. But, don’t confuse this with the 502 gateway error where the error happens after the 60 seconds timeout in the queue. 

If you want to see whether one of your plugins is the reason behind the 504 error message, then you can start to deactivate all plugins. This won’t result in data loss, so you don’t have to worry about losing any valuable information or functionality of your site. 

If you have access to your admin area, you can do this quickly and easily by selecting “Deactivate” in the “Plugins” section from the actions menu. This will result in all your plugins being disabled immediately. 

After this you should start activating them one by one, and after each activation you should reload your site to see whether the issue has been resolved. If it has, it means it was the plugin’s fault. After that you can either contact the plugin developer and tell them of the issue or send a request directly to the WordPress repository. 

If you don’t have access to your admin area, you can get inside your side through FTP and rename the plugins folder. You can use ‘plugins_old’ or something of the like and check whether your site works. If it does work, start activating your plugins one by one to find the one responsible for the 504 error message. Rename your folder back to what it was, probably “plugins”, and then start also renaming the plugin folders inside it, of each individual plugin, one by one, until you find the one you need. 

NOTE: Don’t forget to always regularly update your themes and plugins, as well as the core of your WordPress site. Also, don’t forget to check whether you’re running a version of PHP that’s currently being supported. If you’re not sure about any of this, you can reach your hosting provider and they can help you with it. 

If the issue ends up being bad plugin code or an efficient query, then you might want to contact a WordPress developer to fix the problem. 

  1. Check Logs

Consider using your error logs to help you out with the 504 issue. They can help you find what’s causing this error, and can do a great job in particular if it comes from a plugin on your site. 

Some hosts don’t have a logging tool – if your host is one of them, you can add this code to the wp-config.php file and enable logging: 

define( ‘WP_DEBUG’, true );

define( ‘WP_DEBUG_LOG’, true );

define( ‘WP_DEBUG_DISPLAY’, false );

Another thing you can do is to check the log files in Apache and Nginx. They’re usually located here:

Apache: /var/log/apache2/error.log

Nginx: /var/log/nginx/error.log

Conclusion 

So far, we’ve seen that there are many reasons behind the 504 gateway timeout error, and just as many ways to fix it. 

Usually they have to do with server issues, but they can also be caused when your PHP workers queue/backlog is overwhelmed or by 3rd party plugins. 

If you’re in a situation when you’ve reached the maximum of PHP workers, we’d recommend for you to search for a WordPress developer specializing in optimizing web performance. So, if you go thoroughly through your site and find out that your theme, your plugins and your queries are doing well, it means that it’s time to do an upgrade of your plan or maybe raise the number of PHP workers. 


Leave A Response

* Denotes Required Field