The 504 Gateway Timeout error is 1 of the most common HTTP 5xx errors faced past website owners and site visitors. For many WordPress blogs and ecommerce platforms, knowing how to set server errors like this is crucial to keep their hard-earned visitors from bouncing to competitor sites.

As the 504 Gateway Timeout error doesn't tell you lot why information technology occurred, it'south hard to pinpoint what's causing the server timeout. This commodity will help you understand information technology in particular, learn how to diagnose its cause, and and then fix it.

Later on trying all the various solutions mentioned in the postal service, your site should be up and running in no time.

Sounds interesting? Let's dive in!

Prefer to scout the video version?

The 504 Gateway Timeout error is one of the near mutual HTTP 5xx errors faced past website owners and site visitors. 🤔 Larn how to prepare it with this guide quickly. ⬇️ Click to Tweet

What Is the 504 Gateway Timeout Error?

Every time you visit a website in your browser, the browser sends a asking to the web server where the site is hosted. The server processes the request and responds with the requested resources.

Illustration of how HTTP requests and responses work
How HTTP requests and responses work.

The server response includes ane of many HTTP status codes to indicate the response'southward condition to the browser. But non all these HTTP status codes are errors. For instance, a 200 OK condition code means that the server candy the request successfully and "Everything is OK."

The 5xx course of HTTP status codes indicates that something'southward wrong with the server, the server is aware of it, and it cannot deport out the customer asking. Every bit a result, they're likewise referred to equally Server Fault 5xx status codes.

Officially, v condition codes are specified under the 5xx form (500, 501, 502, 503, 504). You may come up upon many unofficial codes too (506, 507, 509, 520, etc.).

The Internet Technology Task Force (IETF) defines the 504 Gateway Timeout error equally:

The 504 (Gateway Timeout) status lawmaking indicates that the server, while acting equally a gateway or proxy, did non receive a timely response from an upstream server it needed to access in order to complete the request.

To simplify it further, this mistake occurs when two servers are involved in processing a request. The starting time server (typically the main server) times out, waiting for a response from the second server (upstream server).

The 504 Gateway Timeout fault manifests itself in various forms. Here are some ways it unremarkably shows up:

The HTTP ERROR 504 in Chrome browser
The 'HTTP Error 504' in the Chrome browser.

The 504 Gateway Timeout error is similar to the 502 Bad Gateway error, which indicates that the commencement server received an invalid response from the second server (upstream server).

504 GATEWAY TIMEOUT status code in Chrome DevTools
The '504 GATEWAY TIMEOUT' condition code in Chrome DevTools.

Variations of the 504 Gateway Timeout Error

The browser displays whatsoever 504 Gateway Timeout error inside it, merely like whatsoever other fault. As in that location are diverse operating systems, web servers, browsers, and user agents, it can evidence upwards in multiple means.

Below are a few common 504 fault message variations that yous may come across:

  • 504 Gateway Timeout
  • 504 Gateway Timeout NGINX
  • NGINX 504 Gateway Timeout
  • Gateway Timeout Error
  • Mistake 504
  • HTTP Fault 504
  • HTTP Mistake 504 — Gateway Timeout
  • HTTP 504
  • 504 Error
  • Gateway Timeout (504)
  • This page isn't working — Domain took too long to respond
  • 504 Gateway Fourth dimension-out — The server didn't respond in time
  • The page asking was canceled because it took also long to consummate
  • Site visitors: There was an result serving your asking, please attempt over again in a few minutes.
  • Site Owners: There was a gateway timeout. Yous should visit your error log for more information.
  • A bare white screen

All the above error responses, though worded differently, point to the same 504 Gateway Timeout server error.

Web servers and websites can customize how they show the 504 Gateway Timeout error to users. Some of them tin be cool! Information technology'south an excellent tactic to quell their visitors' thwarting.

GitHub's customized HTTP 504 error page
GitHub's customized HTTP 504 error page.

SEO Impact of the 504 Gateway Timeout Fault

All 5xx errors preclude a webpage from loading, making them detrimental to user experience. Hence, search engines like Google take these errors seriously. If the error persists for a long duration, it may even lead to deindexing the webpage from the search engine results.

For example, when Google spiders stumble upon a 503 Service Unavailable error, they'll understand that information technology's a temporary consequence as it'southward mostly used to enable site maintenance mode. Thus, they'll try to crawl the page again later.

A 504 Gateway Timeout fault isn't necessarily temporary as it can be due to multiple reasons. If your site is downwardly for just a few minutes, and if the spiders are trying to clamber it multiple times every minute, they'll try to serve the folio from their enshroud.  They wouldn't even notice information technology.

Merely if your site is down for half-dozen+ hours or more than, then Google will consider the 504 error as a serious site-wide consequence that you need to prepare as soon every bit possible. This tin can touch on your SEO negatively.

Viewing the crawl errors in Google Search Console
Viewing the crawl errors in Google Search Console

Google Search Console is i of the best SEO tools to monitor your website's HTTP 5xx errors.

Causes of the 504 Gateway Timeout Error

As the 504 fault is due to a timeout betwixt servers, the problem probably isn't with the client's device or internet connexion. That too includes your device and connexion.

A 504 Gateway Timeout mistake indicates that the spider web server is waiting too long to answer from another server and "timing out." There tin can be many reasons for this timeout: the other server is not operation properly, overloaded, or down.

The other server need not always exist external (e.thousand. CDN, API gateway). Information technology can besides exist a server-like entity within the main web server (eastward.k. contrary proxy server, database server).

How to Fix the 504 Gateway Timeout Error

Without knowing exact details about the WordPress site, such equally its server configuration, hosting plan, third-political party plugins, and the traffic information technology attracts, yous may observe it frustrating and overwhelming to fix a 504 Gateway Timeout error.

Since many variables are involved, I recommend you lot to offset past fixing client-side issues, which are pretty rare, and and then move towards fixing server-side bug. They're ordinarily the culprits with 504 errors.

Endeavor Reloading the Webpage

One of the showtime things you lot can try when encountering a 504 Gateway Timeout error is to wait a few minutes and try reloading the folio.

You can press the F5 keyboard shortcut to refresh/reload the webpage in most browsers. To remove the folio's browser cache before reloading, you can press the CTRL+F5 shortcut combo instead.

Refreshing a webpage in Chrome browser
Refreshing a webpage in Chrome browser

While you're at it, yous can also endeavour loading the site in a different browser to dominion that out as an issue. As nigh 504 errors are due to temporarily overloaded servers, using this solution should brand your site come up right back.

If waiting and reloading the site doesn't set the 504 mistake outcome, you can check whether a site is down for everyone or just you lot. Ii useful online tools to test a site for downtime are Downwards for Everyone or Just Me and Is It Down Right At present?

Testing Kinsta.com on Down for Everyone or Just Me
Testing Kinsta.com on Downward for Anybody or Just Me

Reboot Your Network Devices

Sometimes, bug with your network devices like modem or router could lead to a 504 Gateway Timeout error. Rebooting these devices could help yous with fixing the problem.

While yous can switch off all these networking devices in any order, the order y'all switch them dorsum on is important. Typically, turn these devices on from the "outside-in," post-obit the connection order from the internet service provider to your chief client device.

Check Your Proxy Settings

A proxy server sits betwixt your device and the internet. Information technology'south mostly used to raise online privacy past hiding private information (e.g. device location) from websites and webservers (e.g. using a VPN).

While it's rare for proxy servers to cause a 504 mistake, incorrect proxy server settings can sometimes be the reason. You can disable the proxy server and effort reloading the webpage to come across whether it'll fix the error.

Changing the 'Proxy' settings in Windows 10
Changing the 'Proxy' settings in Windows x

About clients don't use a proxy service, and so you tin skip this pace if you're confident that you don't use whatsoever proxy server. However, you might have ready it without you even knowing about information technology. I'd propose you check your device's and browser's proxy settings to rule this cause out.

DNS Issues

A 504 Gateway Timeout error can also be caused by DNS bug on the server-side or the client-side (or both).

The most probable reason for a server-side DNS consequence is the FQDN (fully qualified domain name) not resolving the correct IP address or the DNS server not responding. Usually, this occurs when you've just migrated your WordPress site to a new server or host. Hence, it's important to wait for the domain'southward DNS records to propagate fully, which can have upwards to 24 hours.

You lot can use free tools similar whatsmydns.net DNS Checker or DNSMap to meet if your DNS has propagated around the globe.

Checking DNS propagation for your domain on whatsmydns.net
Checking DNS propagation for your domain on whatsmydns.net

For fixing client-side DNS issues, yous could endeavor flushing your local DNS cache. Information technology'south like clearing your browser cache, except here, y'all're flushing the DNS cache from the operating organization.

If yous're using Windows, yous can affluent the DNS cache by opening the Command Prompt and entering the following directive:

          ipconfig /flushdns        
Flushing the DNS Cache with Command Prompt
Flushing the DNS Cache with Command Prompt in Windows

You should run into a "Successfully flushed the DNS resolver Cache." message if it worked.

For the latest macOS versions, yous can open the Terminal and run the post-obit command:

          sudo killall -HUP mDNSResponder        

You won't run into any notification in macOS when the procedure finishes, but you tin change that by appending the command with your custom bulletin.

          sudo killall -HUP mDNSResponder; DNS Cache was cleared successfully        

If you're using older macOS versions, the command you need to enter varies based on which version of macOS yous're running. For more details, you can refer to the macOS section in Kinsta's in-depth flush DNS tutorial.

If y'all're using the Linux operating organization, then the procedure is quite similar to macOS as even Linux uses the Terminal every bit its command-line interface. Since there are many Linux distributions, the exact command you need to run may vary from one distro to another. You can check out Kinsta's guide for more than information.

Finally, you lot can modify your client-side DNS servers temporarily. By default, your ISP assigns the DNS servers automatically to you. Only you lot can change these to public DNS IPs temporarily.

Some reliable DNS servers you can try out are Google Public DNS, Cloudflare 1.1.1.i, Quad9 DNS, and Cisco OpenDNS.

Settings custom DNS servers in Windows 10
Settings custom DNS servers in Windows ten

Disable Your Site'due south CDN Temporarily

Sometimes, the outcome could as well be with your content delivery network (CDN). If a site's origin server isn't reachable, most CDNs volition try to serve the total webpage from their cache.

But most CDNs don't enable this feature by default as it's circuitous to cache dynamic assets on about sites (e.thou. the WordPress admin dashboard).

Setting the 'Cache Everything' page rule in Cloudflare
Setting the 'Cache Everything' page rule in Cloudflare

A straightforward way to troubleshoot this is to disable your CDN temporarily. For example, if you're using the free CDN Enabler WordPress plugin to link your site assets to the CDN URLs, and so you can deactivate the plugin and test reloading your site.

The aforementioned goes for using any other plugin you may apply to connect to your CDN (due east.thou. WP Rocket, Breeze, W3 Total Cache).

If you can't access your site'south admin dashboard, you can disable the plugin via SFTP past renaming the plugin'due south folder proper noun.

Disable all plugins via SFTP by renaming the plugins folder name
Disable all plugins via SFTP past renaming the plugins folder name

CDNs like Cloudflare or Sucuri, which provide full proxy services, have actress firewalls between their edge servers and your origin server. Hence, you lot may meet HTTP 5xx errors more oftentimes while using them. Most of them cache 5xx errors returned by your origin server, so it's easy to troubleshoot them.

Cloudflare's costless plan is prone to throw up a 5xx fault. Unfortunately, since it'southward a full proxy service, in that location's no quick way to disable it. But before you lot blame Cloudflare for it, know that Cloudflare shows two variations of the 504 Gateway Timeout error.

504 Gateway Timeout at Cloudflare (Variation 1)

Cloudflare will prove you a custom 504 Gateway Timeout error screen when your site's origin server responds with a standard HTTP 504 response.

Cloudflare's custom Error 504 screen
Cloudflare's custom Error 504 screen

Here, the issue lies with your web server and not Cloudflare. Y'all can endeavor fixing it with the other solutions mentioned below or contact your hosting provider'due south support for technical help.

504 Gateway Timeout at Cloudflare (Variation 2)

If Cloudflare causes the 504 Gateway Timeout error, the fault screen will mention "cloudflare," which is currently the standard server name for all Cloudflare assets. Usually, the mistake screen will appear as below:

504 Gateway Timeout error caused by Cloudflare
Error screen for 504 Gateway Timeout acquired by Cloudflare

Since Cloudflare itself is unresponsive, you'll not see whatsoever Cloudflare-branded error screen here.

Virtually likely, Cloudflare is already aware of the issue and is working on a fix already. Yous can confirm this by checking the Cloudflare System Status webpage. Alternatively, yous can arrive touch with Cloudflare support for a quicker resolution.

Check Cloudflare System Status at cloudflarestatus.com
Bank check Cloudflare System Status at cloudflarestatus.com

504 Gateway Timeout at Cloudflare Due to Big Uploads

The size of your uploads to your site tin can as well be a reason for the server timeouts. Cloudflare limits upload file size (per HTTP Mail service request) to merely 100 MB on both Free and Pro plans.

Cloudflare's 'Maximum Upload Size' limits for various plans
Cloudflare'due south 'Maximum Upload Size' limits for various plans

The issue tin can be on your host's end or with Cloudflare. You can find out the exact cause by bypassing Cloudflare with your DNS hosts file and trying your upload again.

If you're using Cloudflare with WordPress, I recommend using their gratuitous plugin and excluding critical URLs from caching (such equally the WordPress admin dashboard). You can refer to Kinsta's detailed post on how to configure Cloudflare settings for WordPress.

Suggested reading: How to Ready Cloudflare APO for WordPress.

Server Issues (Cheque With Your Host)

Server issues are 1 of the most mutual reasons for facing a 504 Gateway Timeout error. Since most WordPress sites are hosted on Nginx or Apache webservers, Nginx or Apache is waiting for a response from something and timing out.

Many clients come to Kinsta for exactly this problem they're facing at other WordPress hosts. The chat goes something like this:

We're getting around 100k visitors per month with more than than 200k views. Currently, nosotros're hosting with ____ and we experience 504 errors constantly due to server overload. I don't similar how ____ handled the problem, and we were besides brash that nosotros will have to move to their dedicated plans soon, which I believe is not necessary.

High-traffic and ecommerce sites are more than decumbent to getting 504 errors considering of server overload equally they generate many uncacheable requests. However, this upshot tin can crop with any site, including simple blogs. Many hosts volition ask you to upgrade to a high-tier plan to set the issue, which in almost cases is unnecessary.

Subscribe At present

Kinsta uses LXD managed hosts and orchestrated LXC software containers for each site. Thus, every WordPress site is housed in its own isolated container with access to all the software required to run it (Linux, Nginx, PHP, MySQL). The resources are 100% private and aren't shared with any other site, fifty-fifty your sites.

Near WordPress hosts providing shared hosting plans don't have this capability. Hence, a high-traffic site hosted on the same server as yours may cause your site to throw upwardly a 504 error too.

Apart from isolating each site in its container, Kinsta has also designed its infrastructure to handle thousands of concurrent connections hands. Kinsta even hosts the MySQL databases at localhost, not a remote server. This ways no latency between machines, resulting in faster queries and fewer chances of timeouts occurring.

Many clients who drift to Kinsta see huge decreases in overall load times.

A 212.5% increase in performance after switching to C2.
A 212.5% increase in functioning afterward switching to C2.

An overloaded server isn't the only cause for a server timeout. At that place tin be many other reasons for the 504 mistake:

Slow Server Infrastructure

The server you lot employ to host your WordPress site may not have enough resources to handle the load. It'south similar playing a modern, graphics-intensive videogame on a decade-old PC.

The server just hangs upward trying to serve the website. The only solution to this trouble is to upgrade to a server with ameliorate infrastructure. For this reason, fifty-fifty Kinsta's nearly basic WordPress hosting plan will handle a static site with medium traffic.

Needs More than PHP Workers

PHP workers are used to execute your WordPress site'due south code. An ecommerce site that gets l,000 visitors per month needs a lot more resources than a uncomplicated web log with the same amount of traffic. If all the server'south PHP workers are busy, they'll build up a queue.

When the queue gets besides large, the server disregards old requests, which may crusade the server to throw up a 504 gateway error. You lot can ask your host about increasing your number of PHP workers. This'll permit your site to execute multiple requests simultaneously.

Firewall Issues

Your server's firewall could have some errors or an improper configuration. Perhaps, a few of its rules forestall the server from establishing a connectedness properly. To know if your firewall is the culprit, you tin can cheque your server's error logs.

Network Connectivity Bug

Connectivity bug between the proxy server and the web server could cause delays in responding to HTTP requests. If y'all use a load balancer, there could too be network connectivity issues with information technology.

HTTP Timeouts

HTTP timeouts can occur when a connectedness betwixt the web server and the client is kept open for too long. With WordPress sites, this ordinarily happens when running WordPress imports. One mode to resolve this issue is to switch to a faster internet connection.

You tin also employ a tool with back up for WP-CLI to run the scripts straight on the server, bypassing the HTTP connection entirely. For case, you can use the wp import WP-CLI command to run the WordPress Importer plugin direct through the command-line interface.

Important: 504 Gateway Timeout errors look similar to 503 Service Unavailable errors or 502 Bad Gateway errors. But they're all different. If you lot're experiencing a 504 error at Kinsta, open a support ticket to become your issue stock-still immediately.

For monitoring your site'south downtime on your own, you can utilise a tool like updown.io. It'll check your website'due south status (or any URL) periodically by sending an HTTP request to it. Y'all can set the check frequency from 15 seconds to 1 hour. If your website isn't responding correctly, it'll notify you with an email or an SMS.

Monitor your website with updown.io
Monitor your website easily with updown.io

Yous'll get a generous quantity of free credits with every account of updown.io, just if you lot're looking for cheaper alternatives, you can check out WebGazer or UptimeRobot. Both these tools volition help you monitor your site'due south uptime every 5 minutes for free. That'south decent plenty for most website owners.

WebGazer website monitoring tool's dashboard
WebGazer website monitoring tool's dashboard

Monitoring your website will give you an thought of how often it's downwardly. This is especially helpful if you're using a shared hosting provider. Nearly managed WordPress hosts take intendance of this automatically for yous. Hence information technology's e'er recommended to get with them.

For a detailed explanation, check out Kinsta'south postal service on the importance of managed WordPress hosting.

Spam, Bots, or DDoS Attacks

Malicious attackers can bring your web server to a crawl past sending likewise many and/or resource-intensive requests. If your site is getting spammed past bots or undergoing a DDoS attack, it can overwhelm your server and outcome in 504 Gateway Timeout errors for many genuine users.

Yous can await at your server traffic and analytics to see if y'all can spot any irregular patterns in the site traffic. If you're using Kinsta to host your site, you lot can view this data hands by going to your MyKinsta Analytics dashboard.

MyKinsta Analytics dashboard
MyKinsta Analytics dashboard

Showtime your investigation past looking at the top client IPs. It'll give you an idea of who generates the maximum number of requests, and from where. If your server suddenly uses up enormous bandwidth or attracts a lot of traffic, then this report volition come up in super handy.

Viewing 'Top Client IPs' in MyKinsta dashboard
Viewing 'Top Client IPs' in MyKinsta dashboard

Next, yous can check out the Cache Analysis report. Here, you can see how many requests are bypassing or missing the cache, or being served from the cache. For operation and stability reasons, y'all want to cache as many requests every bit possible, but it's not always possible to achieve that.

For instance, WooCommerce sites generate many uncacheable requests for features such equally the shopping cart and the checkout process.

The 'Cache Analysis' screen in MyKinsta
The 'Cache Analysis' screen in MyKinsta

Finally, you can utilize a WordPress security plugin to beefiness upwardly your website's security past spotting and blocking worrisome traffic/IPs. You can ask your host to block certain IPs too.

Depending upon the length and scale of the set on, this could be a never-ending procedure of blacklisting IPs equally many attackers change their IPs and proxy addresses after getting blocked.

Annotation: Kinsta doesn't allow its clients to install WordPress security plugins as they tin have a huge effect on the site'due south functioning, peculiarly its scanning capabilities. As Kinsta uses load balancers with Google Cloud Platform, blocking IPs wouldn't always work as intended.

You can use dedicated security solutions such equally Cloudflare or Sucuri to protect your sites from DDoS attacks and spambots. For more, you can check out Kinsta's articles on how to install Cloudflare on your WordPress site and how Sucuri helped stop a DDoS attack in its tracks.

Corrupted WordPress Database

Sometimes, a 504 Gateway Timeout error can be considering of a corrupt database, peculiarly in WordPress sites. Typically, this is due to corrupted database tables or files. Sometimes, it can as well be caused past a serious security issue like your site or database being hacked.

Repairing a corrupted WordPress database depends on the problem. Plugins like WP-DBManager make it piece of cake to diagnose database issues and repair them. I recommend you to read Kinsta's detailed walkthrough on repairing WordPress database issues to get started.

Check Your Site's Plugins and Themes

In most cases, third-party plugins and themes don't cause 504 errors. But at that place'due south a slight risk that they might cause server timeouts, usually by queuing up many uncached requests generated by the plugin/theme. Every bit this ties up a lot of your server'due south PHP workers, it can crusade 504 errors.

A slap-up example of this issue is WooCommerce, a plugin installed to add ecommerce functionality to WordPress sites.

The simplest way you can troubleshoot this problem is by deactivating all your plugins. Think, you won't lose any information if you lot just conciliate a plugin.

If you can access your admin dashboard, you tin can go to the Plugins screen, select Deactivate from the bulk deportment carte, checkmark all the plugins, and then striking the Apply push. This will disable all of your plugins.

Deactivate plugins in WordPress
Deactivating all the WordPress plugins through WP admin dashboard

If you tin't access your admin area, you can disable plugins via SFTP using the method described before. Merely rename the primary plugin folder name to disable all the plugins in bulk.

Once you've deactivated all the plugins, check whether your site loads properly. If it works, yous must activate each plugin, testing the site after enabling every plugin.

Finally, make certain that your plugins, themes, and WordPress core are upwardly to appointment. Also, ensure that your server is running the recommended version of PHP.

If you experience this to exist too overwhelming, you tin e'er achieve out to your host for assist. Kinsta uses Kinsta APM and other troubleshooting techniques to aid clients narrow down what plugin, query, or script might crusade the error.

In the worst-case scenarios, like an inefficient query or bad code in a plugin/theme, you can bring in a WordPress programmer to fix the consequence.

Check Fault Logs

Viewing fault logs can exist very helpful when troubleshooting and debugging 504 errors on your WordPress site. This can aid yous narrow down an issue on your site quickly, peculiarly if it's resulting from a enervating plugin on your site.

If you're a Kinsta customer, you can easily see errors in the log viewer in your MyKinsta dashboard.

Checking error logs inside MyKinsta dashboard
Checking mistake logs inside the MyKinsta dashboard

If your host doesn't have a logging tool, then you can enable WordPress debug style by adding the following code to your wp-config.php file:

          define( 'WP_DEBUG', true ); define( 'WP_DEBUG_LOG', truthful ); define( 'WP_DEBUG_DISPLAY', false );        

The WP_DEBUG constant enables or disables the WordPress debug mode. Information technology has two optional companion constants that can extend its features. The WP_DEBUG_LOG abiding directs all errors to be saved to a debug.log file within the /wp-content/ directory. If y'all don't encounter this file, y'all tin e'er create one.

The WP_DEBUG_DISPLAY constant controls whether debug logs testify up on the HTML folio. Setting this to false will hide all errors, but you can review the errors later, as you lot've as well defined WP_DEBUG_LOG as true.

Of import: If you have WP_DEBUG enabled in the Kinsta surround, it'll route all errors to the debug.log file and non the error.log in the MyKinsta dashboard.

Yous tin can also download the raw WordPress error log files via SFTP. Typically, you tin find error logs in your server's root directory in a folder named "logs."

Accessing the WordPress error logs folder via SFTP
Accessing the WordPress error logs binder via SFTP

Kinsta users can too enable WordPress debug fashion from their MyKinsta dashboard. To do that, navigate to Sites > Tools > WordPress Debugging and click the Enable button. This will allow you to see PHP errors and notices without enabling debug mode via SSH or SFTP.

Lastly, you lot tin check the server log files. Depending on which server you're using to host your WordPress site, they're commonly found in these locations:

  • Apache: /var/log/apache2/error.log/
  • Nginx: /var/log/nginx/mistake.log/

You lot can refer to logging related documentation of Apache or Nginx for more information.

Configure Apache or Nginx Settings Properly

Y'all can edit your server config files to increase resource limits for specific directives. This tin help you resolve the 504 Gateway Timeout error.

For Apache Webservers

Showtime, add together the following code to your httpd.conf:

          TimeOut 600        

This setting defines how long the server will wait for sure requests before marking it as a network timeout issue. Its default value is sixty seconds (Apache 2.4 version).

Yous tin can merely add this directive in your httpd.conf file, not in your .htaccess file. Since almost shared hosting providers don't allow you to alter the httpd.conf file, you tin try increasing the value of the LimitRequestBody directive in your .htaccess file instead.

Then add the following line to your php.ini file:

          max_execution_time 300        

The default value of PHP'due south max_execution_time directive is 30 seconds. Increasing it will allow your site'southward PHP scripts to run longer.

For Nginx Webservers

If you're running your WordPress sites on Nginx + FastCGI Process Managing director (PHP-FPM) or using Nginx equally a reverse proxy for Apache, you can tweak the server settings to assist prevent 504 Gateway Timeout errors.

504 Gateway Timeout Error on Nginx + FastCGI (PHP-FPM)

First, you must edit your PHP-FPM pool config file. You can find it at the /etc/php7.4/fpm/pool.d/www.conf location in your Nginx server (the exact path may vary based on the PHP version). Alternately, yous tin run the following command in your concluding to edit the PHP-FPM pool config file:

          sudo nano /etc/php/7.ii/fpm/pool.d/www.conf        

Next, fix the post-obit directive:

          request_terminate_timeout = 300        

After this, y'all must edit your php.ini file. Y'all tin locate it at /etc/php.ini. Open the file and add/change the value for the max_execution_time directive to 300 seconds.

          max_execution_time = 300        

Finally, add together the following code to your nginx.conf file'southward location block:

          location ~ .php$ { ... fastcgi_read_timeout 300; }        

Reload Nginx and PHP-FPM for the changes to take effect.

          sudo service nginx reload sudo service php7.4-fpm reload        

The exact lawmaking to reload PHP-FPM will vary based on the PHP version installed on your server. Exam your site to see whether it has fixed the outcome.

504 Gateway Timeout Error on Nginx Proxy

If yous're using Nginx every bit a contrary proxy server for Apache, then you lot can arrive more lenient towards server timeouts by adding the following directives to your nginx.conf file:

          proxy_connect_timeout 600; proxy_send_timeout 600; proxy_read_timeout 600; send_timeout 600;        

Don't forget to reload Nginx after making your changes.

sudo service nginx reload

Other HTTP Errors Similar 504 Gateway Timeout

As mentioned earlier in the article, many other HTTP 5xx errors are merely like the 504 Gateway Timeout fault. Information technology's because they all happen on the server-side. These errors include:

  • 500 Internal Server Error
  • 501 Non Implemented Error
  • 502 Bad Gateway Error
  • 503 Service Unavailable Error

Other HTTP errors caused due to client-side bug, like the 404 Not Found error, are also like the 504 error. You tin refer to Kinsta's detailed guide and list of HTTP status codes for more than information.

When you don't know what caused a 504 Gateway Timeout mistake, how practise you fix it in time to keep hard-earned visitors from billowy to competitor sites? 🤷‍♂️ All the details are in this post. ⬆️ Click to Tweet

Summary

Your WordPress site can exist affected by the 504 Gateway Timeout error because of multiple reasons. In this commodity, you learned how to troubleshoot them all. Typically, these errors are caused due to server-side bug, in which case you tin accomplish out to your host and get information technology resolved quickly.

Withal, you must also sympathize that this fault can be due to third-party plugins, themes, services, inefficient database queries, or a combination of two or more than of these. If yous're maxing out your server's resources (east.g. PHP workers), information technology's recommended to optimize your site for operation.

If y'all nevertheless notice that your website is timing out, and then it might very well be that you need to upgrade your hosting plan or the number of PHP workers. I recommend you to consider this pick only afterwards you lot've exhausted all the other solutions described in this commodity.

From unproblematic static sites to complex ecommerce and membership sites, Kinsta'southward scalable hosting plans are designed to adjust all types of websites. To learn more than near our scalable deject hosting, bank check out this article!

Did we miss anything? If y'all're withal finding it difficult to fix the 504 Gateway Timeout error on your WordPress site, leave a comment below.


Save time, costs and maximize site performance with:

  • Instant help from WordPress hosting experts, 24/7.
  • Cloudflare Enterprise integration.
  • Global audience accomplish with 32 data centers worldwide.
  • Optimization with our congenital-in Application Performance Monitoring.

All of that and much more, in one program with no long-term contracts, assisted migrations, and a 30-day-money-back-guarantee. Check out our plans or talk to sales to observe the plan that's right for you.