How To Fix 504 Gateway Timeout Error On Your WordPress Website?
How To Fix 504 Gateway Timeout Error On Your WordPress Website?
Search …
There is nothing more annoying than a blank screen with an error message instead of your
website’s content. Today, we’ll take a look at the 504 Gateway Timeout Error, and also give
some recommendations on how to fix it on your WordPress site. For most blogs and online
stores, such errors can lead to loss of revenue. The visitors immediately leave the resource
with a bad experience, and cannot make purchases. So let’s dive in –
HTTP status codes starting with 5 are server-side errors. They appear when the request
cannot be performed due to a connection failure between several servers.
504 Gateway timeout error is an HTTP status code. It appears when one server does not
receive a timely response from another one that works as a gateway or proxy. Simply put,
this means that the server could not complete your request within some period.
There are many error messages that you might see. Some common errors that you might
have encountered:
As there are a variety of web browsers, operating systems and types of servers, they
display the 504 error in many ways. All of them, as a rule, means the same. We listed some
of the most popular version:
Before we consider the error itself, it is important to understand why it appears. Whenever
you start your browser and visit a URL, it sends the request back to the server where it is
hosted. The web server then processes the request and sends you the requested resources
along with an HTTP header. This header contains one of the many HTTP status codes that
let you understand whether everything is okay or something went wrong. Not all status
codes are bad. For example, the status code 200 indicates that everything works fine.
Any status code in the 500-s is error codes (500, 501, 502, 503, 504, etc.) that have
different meanings. They indicate that the request was accepted, but the server could not
execute it.
To that extent, the 504 error means that the server running as a gateway is out of time to
wait for a server response. The code is returned when there are two servers involved in
processing the request, and the response time from the second server has expired.
In addition to server timeouts, there are other causes, leading to 504 error:
Slow server. It is possible that the server where you host your WordPress website is
responding too slowly, and therefore it generates gateway errors.
Insufficient PHP workers. PHP workers are used to running code on your WordPress
site. Demanding sites can make all PHP workers busy. In that case, they form the
queue. If the queue and the backlog are full, old requests are ignored. You can ask
your hosting to increase the number of PHP workers. Additional PHP workers for a site
allow executing several requests simultaneously.
Problems with the firewall. The firewall on your server may contain errors due to
incorrect configuration or rules blocking the connection.
Network connection. If there is a problem with the network connection between the
proxy server and the webserver, this can lead to delays. Also, there may be network
problems with the load balancer, if it is used.
When you see a 504 Gateway timeout error, you might be confused about what to do? You
can always try the following actions –
One of the first things you should do when you face the 504 Gateway Timeout Error is just
to wait a minute and reload the page. Perhaps the hosting or server is simply overloaded,
and the site will quickly return to work.
In case the site is online, but you still see the 504 gateway timeout error, try changing your
browser to another one. Clear the browser cache or use the incognito mode, this can also
help determine if the error is caused by the browser.
Try opening the site on different computers, on different networks or on mobile devices. If
nothing could help to fix the 504 gateway timeout error, this step will help you determine if
the problem is on the server side or it is local.
Sometimes you may get 504 error if you use a proxy server. These cases are very rare,
especially on the client-side. Read the guides on how to disable proxy on Windows and
Mac.
1 ipconfig / flushdns
You should see the “Successfully flushed the DNS Resolver Cache” message.
In macOS, type the following in the terminal:
1 dscacheutil -flushcache
Also, the problem may relate to the content delivery network. If you use a third-party CDN
provider, you can try to temporarily disable it. For that, you may use the WordPress plugins.
With them, you will be able to disable the CDN safer.
If you use the back proxy services like Cloudflare or Sucuri, they may cause the 504 error
as they use the additional firewall. Most of them cache 500 state codes when they are
returned by your source server. Many users noticed that issue on Cloudflare free plan.
Unfortunately, since Cloudflare is a complete proxy service, there is no quick way to
disconnect it.
However, before blaming the Cloudflare, it is important to know that there are two types of
504 error:
504 Gateway Timeout in Cloudflare (version 1)
If you see the page looking like that, then, in this case, the problem is on the Cloudflare
side. Contact their user support. Or check their status page. Most likely, they are already
notified about this problem and are working on it.
504 Gateway Timeout in Cloudflare (version 2)
If you see the page looking like that, then this is a problem with your WordPress hosting.
Please follow the recommendations from the next section.
Server problems are one of the common reasons why users experience 504 errors on their
WordPress websites. In simple terms, Nginx or Apache wait for a response until the waiting
time has expired.
504 errors are really very popular on sites with a lot of visitors and on e-commerce sites and
online stores. The latter may have installed e-commerce plugins like Woocommerce. They
usually have many non-cached requests. This can cause the server to overload. However,
such error can happen to a variety of website types, including the blogs. Many hosters
usually offer to upgrade to a more expensive tariff plan to fix this problem. And even if this
usually helps to solve this issue, it is often not necessary.
Some hosting provide dedicated resources for each server. This means that each site is
hosted in its own isolated container. It has all the necessary software resources required to
run it (Linux, Nginx, PHP, MySQL). Resources are 100% confidential and do not share with
anyone. But some shared WordPress hosting plans do not have this feature. So any
neighbouring site with high traffic will cause 504 gateway timeout error on your site.
It is also important to note that 504 errors may look very similar to 503 errors (service
unavailable) or even 502 errors (bad gateway). But actually, they are different.
If you want to prevent such errors in the future, you can use a tool like statuscake.com to
track the server state and immediately report any problems. The service periodically sends
an HTTP HEAD request to the specified URL. You can simply set your homepage. In
addition, you are able to choose the checking frequency from 15 seconds to 10 minutes.
The service will send you an email if your site is out of service, indicating the time when it
happened.
This can be especially useful if you are using a virtual hosting, which, as a rule, is
constantly overloaded. This will give you proof that your site did not work (for example, at
night). For this reason, we advise you to move on to dedicated hosting.
Clean the site from spam, bots and protect it from DDoS attacks:
Perhaps your website has been spammed by bots or became a DDoS attack target.
Sometimes this leads to uncached requests and, as a result, to server overload. All that
results in a 504 gateway timeout error. You can learn the server analytics to see if there are
any patterns in it. You can request your hosting provider for this information.
The first report, which we recommend studying, is the top-end customers IP addresses.
Usually, this is very useful, especially if your site suddenly began to generate large traffic or
was attacked by bots.
The second report we recommend to look at is the requests and bots. You can quickly
compare the number of people visiting your website, with the number of bots. However,
remember that not all bots are bad. Google Bot is really a good bot, it scans the site to
index the content and promote it in the search engine.
The third report we recommend is a cache analysis. Here you can see what requests are
missing in the cache, and also what are the top locations of your site. To provide the best
performance and stability, you should try to cache as many requests as possible. This is not
always available because some resources generate a huge amount of uncached requests.
The best example is Woocommerce. These requests are necessary for the correct work and
synchronization.
If on your site you find and identify traffic or IP addresses that need to be blocked, you can
use the WordPress security plugin. However, not all hostings allow you to install security
plugins. First, such plugins can influence the performance, especially when they scan the
server. Second, the IP blocking feature may not work in them because hosting provider can
use load balancers from the Google Cloud Platform.
Naturally, IP addresses can always be blocked by the hosting support service. However,
depending on how long and large is an attack, this can never end. When the attacks or
spam is blocked in one area, they are often switched to other zones, changing IP addresses
or using other proxies. Therefore, in this case, we recommend installing a security solution,
such as Cloudflare or Sucuri.
Many users believe that third-party plugins or themes do not lead to 504 gateway timeout
errors. And in most cases this is true. But, according to many users’ experience, a slow
non-cached plugin request can cause the delays, since it uses more of your PHP workers.
Once you reach the limit of them, the queue will remove your old requests, which can cause
the 504 errors. They should not be confused with 502 errors which are the result of a 60
seconds timeout.
There are several ways to fix the issue. One of them is the deactivation of all your plugins.
Remember that you will not lose your data if you disable them. If you have access to the
admin panel, simply go to the Plugins section and select Deactivate feature. This will
disable all of your plugins.
If this fixes the issue, you need to find its source. Activate the plugins one by one, restarting
the site after each activation. Once you see the 504 error, you will be able to identify the
problematic plugin. Then you can contact the plugin developer for help or create a ticket in
the WordPress repository.
If you do not have access to the admin panel, you can use the FTP client to connect to your
server. Rename the plugin folder to something like plugins_old. Then check your site again.
If this works, you will need to test each plugin separately to find the reason. Rename the
plugins’ folder back. Then rename the plugin folders inside until you find the plugin causing
the issue.
Make sure that all your plugins, themes and the WordPress kernel are updated to the latest
version. And make sure that you are using a supported version of PHP.
If the plugin contains bad code, then you will most likely need to contact the WordPress
developers to solve this problem.
Check the logs:
You can also use your error logs. One can view them in a special section of the hosting
dashboard. You can quickly fix the issue, especially if its source is the website plugin. If
your hosting does not offer logging tools, you can add the following code to the wp-
config.php file to enable logging:
Logs are usually located in /wp-content folder. Sometimes they can be in separate folders.
You can also check the Apache and Nginx logs which are most often located at
/var/log/apache2/error.log (Apache) or /var/log/nginx/error.log (Nginx)
If you are maintaining your own server and WordPress website on Nginx+FastCGI (php-
fpm). Also, you can use the Nginx as a proxy for Apache. In that case, there are additional
settings that you can change to prevent 504 gateway timeout errors.
If you are using Nginx with FastCGI (php-fpm), then you need to first make changes to the
PHP-FPM file. Go to /etc/php5/fpm/pool.d/www.conf (it can vary depending on the PHP
version). Set the following directive:
1 request_terminate_timeout = 300
Then you must modify the php.ini file, which is usually located at /etc/php.ini. Find the
max_execution_time directive. Increase its value to 300 or create a directive if it does not
exist:
1 max_execution_time = 300
Finally, you will need to modify the nginx.conf file. Add the following to your Nginx virtual
host configuration:
1 location ~ .php $ {
2 ...
3 fastcgi_read_timeout 300;
4 ...
5 }
If you use Nginx as a proxy for Apache, then in this case add the following to your
nginx.conf file:
1 proxy_connect_timeout 600;
2 proxy_send_timeout 600;
3 proxy_read_timeout 600;
4 send_timeout 600;
Contact Support
If you constantly face 504 gateway timeout error and nothing helps to fix it, contact the
hosting technical support. Try to describe what steps you have taken to identify the error
cause and provide as much information as possible. This will greatly speed up the process.
Conclusion
As you can see, there are many different ways and methods of fix 504 gateway timeout
error on the WordPress site. Typically, this is a problem with the server, and in this case
you need to contact your hosting to solve them. But it’s important to remember that they can
also be caused by third-party plugins or the queue/backlog overflow of your PHP workers.
W E B S , WE OR RV DE PR RS E S S E R R O R
3 Replies to “How to fix 504 Gateway Timeout Error on your WordPress Website?”
see here
2 9 A P R I L , 2 0 1 9 A T 4 : 3 0 P M
3 M A Y , 2 0 1 9 A T 1 0 : 3 0 A M
Useful information. Lucky me I discovered your web site unintentionally, and I’m stunned
why this
twist of fate didn’t happened in advance! I bookmarked
it.
Reply
raley
1 8 J U N E , 2 0 1 9 A T 4 : 2 7 P M
Thank you so much for detailing this, I’ve been struggling for weeks with the same problem.
Anyway, i am looking for the cheap linux hosting. Can you suggest me the one most
cheapest hosting provider?
Thank you so much.
Reply
Leave a Reply
Your email address will not be published. Required fields are marked *
Comment
Name *
Email *
Website
Save my name, email, and website in this browser for the next time I comment.
Post Comment
P R E V I O U S
Plans & Features Knowledge Base Contact Us How to fix 504 Gateway Timeout Error on
your WordPress Website?
Blog Affiliates Login
All You Need to Know About 502 Error Bad
Tutorials Refund Policy Signup
Gateway
Free Themes Terms & Conditions Knowledge Base How to Fix Error 403 Forbidden for
Privacy Policy Tutorials WordPress
How to Fix
DNS_PROBE_FINISHED_NXDOMAIN
Error?
How To Fix Error 404 Not Found On
WordPress