The 504 Gateway Timeout error is one of the about common HTTP 5xx errors faced by website owners and site visitors. For many WordPress blogs and ecommerce platforms, knowing how to gear up server errors similar this is crucial to continue their hard-earned visitors from billowy to competitor sites.

Every bit the 504 Gateway Timeout error doesn't tell you lot why it occurred, information technology's difficult to pinpoint what'southward causing the server timeout. This article volition help you sympathise it in detail, larn how to diagnose its cause, then fix it.

After trying all the various solutions mentioned in the mail, your site should be up and running in no time.

Sounds interesting? Let's dive in!

Prefer to watch the video version?

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

What Is the 504 Gateway Timeout Error?

Every fourth dimension 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 one of many HTTP status codes to betoken the response'south status to the browser. But not all these HTTP status codes are errors. For instance, a 200 OK status code means that the server processed the request successfully and "Everything is OK."

The 5xx class of HTTP status codes indicates that something's wrong with the server, the server is enlightened of information technology, and it cannot comport out the client asking. As a outcome, they're also referred to as Server Error 5xx condition codes.

Officially, five status codes are specified nether the 5xx course (500, 501, 502, 503, 504). Yous may come upon many unofficial codes too (506, 507, 509, 520, etc.).

The Internet Engineering Job Force (IETF) defines the 504 Gateway Timeout error as:

The 504 (Gateway Timeout) condition code indicates that the server, while acting as a gateway or proxy, did not receive a timely response from an upstream server information technology needed to access in order to complete the asking.

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

The 504 Gateway Timeout error manifests itself in diverse forms. Here are some ways it usually shows up:

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

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

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

Variations of the 504 Gateway Timeout Mistake

The browser displays any 504 Gateway Timeout error inside information technology, just like whatsoever other error. As there are diverse operating systems, web servers, browsers, and user agents, it tin show up in multiple ways.

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

  • 504 Gateway Timeout
  • 504 Gateway Timeout NGINX
  • NGINX 504 Gateway Timeout
  • Gateway Timeout Fault
  • Mistake 504
  • HTTP Error 504
  • HTTP Error 504 — Gateway Timeout
  • HTTP 504
  • 504 Error
  • Gateway Timeout (504)
  • This page isn't working — Domain took as well long to answer
  • 504 Gateway Fourth dimension-out — The server didn't respond in time
  • The page request was canceled because information technology took too long to complete
  • Site visitors: There was an issue serving your request, please endeavor again in a few minutes.
  • Site Owners: In that location was a gateway timeout. You should visit your error log for more information.
  • A blank white screen

All the higher up error responses, though worded differently, bespeak to the same 504 Gateway Timeout server mistake.

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

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

SEO Bear on of the 504 Gateway Timeout Error

All 5xx errors forbid a webpage from loading, making them detrimental to user experience. Hence, search engines like Google have these errors seriously. If the error persists for a long elapsing, it may even atomic number 82 to deindexing the webpage from the search engine results.

For case, when Google spiders stumble upon a 503 Service Unavailable error, they'll understand that it's a temporary issue every bit information technology'due south more often than not used to enable site maintenance fashion. Thus, they'll attempt to crawl the page again later.

A 504 Gateway Timeout mistake isn't necessarily temporary equally it can be due to multiple reasons. If your site is down for just a few minutes, and if the spiders are trying to crawl it multiple times every infinitesimal, they'll endeavor to serve the page from their cache.  They wouldn't even observe information technology.

But if your site is downward for 6+ hours or more, then Google will consider the 504 error as a serious site-wide issue that you need to set up every bit soon as possible. This can impact your SEO negatively.

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

Google Search Panel 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 error is due to a timeout between servers, the problem probably isn't with the client's device or cyberspace connection. That also includes your device and connection.

A 504 Gateway Timeout error indicates that the web server is waiting too long to respond from another server and "timing out." In that location can exist many reasons for this timeout: the other server is not functioning properly, overloaded, or downwardly.

The other server demand not always exist external (eastward.g. CDN, API gateway). It can also be a server-like entity within the main web server (e.g. reverse proxy server, database server).

How to Fix the 504 Gateway Timeout Mistake

Without knowing exact details near the WordPress site, such as its server configuration, hosting plan, 3rd-party plugins, and the traffic information technology attracts, yous may find it frustrating and overwhelming to fix a 504 Gateway Timeout error.

Since many variables are involved, I recommend y'all to start by fixing client-side bug, which are pretty rare, and then motility towards fixing server-side problems. They're ordinarily the culprits with 504 errors.

Try Reloading the Webpage

One of the commencement things you can effort when encountering a 504 Gateway Timeout fault is to wait a few minutes and try reloading the folio.

You lot can printing the F5 keyboard shortcut to refresh/reload the webpage in most browsers. To remove the folio's browser cache earlier 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, y'all can besides try loading the site in a different browser to rule that out as an outcome. As most 504 errors are due to temporarily overloaded servers, using this solution should make your site come up right back.

If waiting and reloading the site doesn't fix the 504 error issue, yous can check whether a site is down for anybody or just you. Two useful online tools to test a site for reanimation are Downwards for Anybody or Just Me and Is It Down Correct Now?

Testing Kinsta.com on Down for Everyone or Just Me
Testing Kinsta.com on Down for Everyone or Merely Me

Reboot Your Network Devices

Sometimes, problems with your network devices like modem or router could lead to a 504 Gateway Timeout fault. Rebooting these devices could assist you with fixing the problem.

While you lot can switch off all these networking devices in any order, the order you switch them dorsum on is important. Typically, turn these devices on from the "outside-in," following the connexion order from the internet service provider to your chief customer device.

Check Your Proxy Settings

A proxy server sits between your device and the cyberspace. Information technology's mostly used to enhance online privacy by hiding private information (eastward.thou. device location) from websites and webservers (eastward.g. using a VPN).

While it's rare for proxy servers to cause a 504 mistake, wrong proxy server settings can sometimes be the reason. Yous tin can disable the proxy server and try 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 ten

Virtually clients don't utilize a proxy service, so you tin can skip this step if y'all're confident that you don't utilise whatsoever proxy server. Yet, you might accept fix it without you lot even knowing most it. I'd propose you check your device's and browser'due south proxy settings to rule this cause out.

DNS Bug

A 504 Gateway Timeout error can also exist caused past DNS problems on the server-side or the client-side (or both).

The almost probable reason for a server-side DNS issue 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 of import to wait for the domain's DNS records to propagate fully, which can take up to 24 hours.

You can apply free tools similar whatsmydns.net DNS Checker or DNSMap to see 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 problems, you could attempt flushing your local DNS cache. It'due south similar clearing your browser cache, except hither, you're flushing the DNS cache from the operating organisation.

If you're using Windows, you lot tin flush the DNS cache by opening the Command Prompt and inbound the following directive:

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

You should see a "Successfully flushed the DNS resolver Cache." bulletin if it worked.

For the latest macOS versions, you tin open the Terminal and run the following command:

          sudo killall -HUP mDNSResponder        

You won't meet any notification in macOS when the process finishes, simply y'all can change that by appending the command with your custom message.

          sudo killall -HUP mDNSResponder; DNS Cache was cleared successfully        

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

If you're using the Linux operating system, and so the process is quite similar to macOS as even Linux uses the Concluding equally its command-line interface. Since in that location are many Linux distributions, the exact control you need to run may vary from 1 distro to another. Yous tin check out Kinsta's guide for more than information.

Finally, you tin can change your customer-side DNS servers temporarily. Past default, your ISP assigns the DNS servers automatically to you. Merely you lot tin can alter these to public DNS IPs temporarily.

Some reliable DNS servers you tin can effort out are Google Public DNS, Cloudflare 1.1.one.1, Quad9 DNS, and Cisco OpenDNS.

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

Disable Your Site's CDN Temporarily

Sometimes, the outcome could also exist with your content delivery network (CDN). If a site's origin server isn't reachable, nigh CDNs volition try to serve the full webpage from their cache.

Simply near CDNs don't enable this feature by default as information technology'south complex to enshroud dynamic avails on most sites (e.m. the WordPress admin dashboard).

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

A straightforward mode to troubleshoot this is to disable your CDN temporarily. For instance, if you lot're using the gratis CDN Enabler WordPress plugin to link your site avails to the CDN URLs, then yous can deactivate the plugin and examination reloading your site.

The aforementioned goes for using whatsoever other plugin you lot may use to connect to your CDN (e.g. WP Rocket, Breeze, W3 Full Cache).

If yous can't access your site's admin dashboard, yous can disable the plugin via SFTP past renaming the plugin'south folder name.

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 total proxy services, have extra firewalls between their edge servers and your origin server. Hence, y'all may come across HTTP 5xx errors more oftentimes while using them. Nearly of them cache 5xx errors returned past your origin server, so it'due south easy to troubleshoot them.

Cloudflare's costless plan is prone to throw up a 5xx error. Unfortunately, since it'southward a full proxy service, at that place'southward no quick way to disable it. But earlier you 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 bear witness you a custom 504 Gateway Timeout error screen when your site'south origin server responds with a standard HTTP 504 response.

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

Hither, the issue lies with your spider web server and not Cloudflare. You can try fixing it with the other solutions mentioned beneath or contact your hosting provider's back up for technical help.

504 Gateway Timeout at Cloudflare (Variation 2)

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

504 Gateway Timeout error caused by Cloudflare
Fault screen for 504 Gateway Timeout caused by Cloudflare

Since Cloudflare itself is unresponsive, you'll not meet any Cloudflare-branded error screen hither.

Most likely, Cloudflare is already enlightened of the event and is working on a set up already. Yous can confirm this by checking the Cloudflare System Status webpage. Alternatively, you can get in bear on with Cloudflare back up for a quicker resolution.

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

504 Gateway Timeout at Cloudflare Due to Big Uploads

The size of your uploads to your site can also be a reason for the server timeouts. Cloudflare limits upload file size (per HTTP POST request) to just 100 MB on both Free and Pro plans.

Cloudflare's 'Maximum Upload Size' limits for various plans
Cloudflare'southward 'Maximum Upload Size' limits for various plans

The event tin can be on your host'due south end or with Cloudflare. You can find out the exact crusade past bypassing Cloudflare with your DNS hosts file and trying your upload again.

If y'all're using Cloudflare with WordPress, I recommend using their free 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 Set up up Cloudflare APO for WordPress.

Server Issues (Bank check With Your Host)

Server issues are one of the nearly common 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 conversation goes something like this:

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

Loftier-traffic and ecommerce sites are more prone to getting 504 errors because of server overload as they generate many uncacheable requests. However, this issue can crop with whatsoever site, including simple blogs. Many hosts will enquire you to upgrade to a high-tier plan to set up the issue, which in nearly 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 ain 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 whatever other site, even your sites.

Most WordPress hosts providing shared hosting plans don't have this capability. Hence, a loftier-traffic site hosted on the same server equally yours may cause your site to throw up a 504 error as well.

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 means no latency betwixt 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 performance after switching to C2.

An overloaded server isn't the just crusade for a server timeout. At that place can exist many other reasons for the 504 fault:

Slow Server Infrastructure

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

The server just hangs up trying to serve the website. The simply solution to this trouble is to upgrade to a server with ameliorate infrastructure. For this reason, even Kinsta's most bones WordPress hosting plan will handle a static site with medium traffic.

Needs More PHP Workers

PHP workers are used to execute your WordPress site's lawmaking. An ecommerce site that gets 50,000 visitors per month needs a lot more resources than a simple blog with the same amount of traffic. If all the server'south PHP workers are busy, they'll build upwardly a queue.

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

Firewall Problems

Your server's firewall could accept some errors or an improper configuration. Perhaps, a few of its rules prevent the server from establishing a connection properly. To know if your firewall is the culprit, you can bank check your server's fault logs.

Network Connectivity Problems

Connectivity issues betwixt the proxy server and the spider web server could cause delays in responding to HTTP requests. If y'all use a load balancer, there could also be network connectivity issues with it.

HTTP Timeouts

HTTP timeouts tin occur when a connection betwixt the web server and the customer is kept open up for too long. With WordPress sites, this usually happens when running WordPress imports. Ane manner to resolve this issue is to switch to a faster internet connectedness.

You lot can also utilize a tool with back up for WP-CLI to run the scripts straight on the server, bypassing the HTTP connection entirely. For instance, you can utilize the wp import WP-CLI control to run the WordPress Importer plugin directly 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're experiencing a 504 error at Kinsta, open up a support ticket to get your issue fixed immediately.

For monitoring your site's reanimation on your ain, y'all tin use a tool like updown.io. It'll cheque your website's status (or any URL) periodically by sending an HTTP request to it. You tin can set the check frequency from fifteen seconds to one 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

You'll get a generous quantity of costless credits with every account of updown.io, only if y'all're looking for cheaper alternatives, you tin check out WebGazer or UptimeRobot. Both these tools volition help you monitor your site's uptime every five minutes for free. That's decent plenty for near website owners.

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

Monitoring your website will requite you an idea of how oftentimes it's down. This is peculiarly helpful if you're using a shared hosting provider. Most managed WordPress hosts take intendance of this automatically for you. Hence information technology's ever recommended to get with them.

For a detailed caption, check out Kinsta'due south post on the importance of managed WordPress hosting.

Spam, Bots, or DDoS Attacks

Malicious attackers tin can bring your web server to a clamber by sending besides many and/or resource-intensive requests. If your site is getting spammed past bots or undergoing a DDoS assault, information technology can overwhelm your server and effect in 504 Gateway Timeout errors for many genuine users.

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

MyKinsta Analytics dashboard
MyKinsta Analytics dashboard

Outset your investigation by looking at the pinnacle client IPs. Information technology'll requite you an idea of who generates the maximum number of requests, and from where. If your server suddenly uses upwardly enormous bandwidth or attracts a lot of traffic, then this written report will come up in super handy.

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

Side by side, yous can bank check out the Enshroud Assay report. Here, you tin see how many requests are bypassing or missing the enshroud, or being served from the enshroud. For performance and stability reasons, you desire to enshroud as many requests every bit possible, only information technology's not always possible to achieve that.

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

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

Finally, yous can use a WordPress security plugin to beef upwards your website's security past spotting and blocking worrisome traffic/IPs. You can inquire your host to block certain IPs too.

Depending upon the length and scale of the assault, this could exist a never-ending procedure of blacklisting IPs as many attackers change their IPs and proxy addresses after getting blocked.

Annotation: Kinsta doesn't allow its clients to install WordPress security plugins every bit they can take a huge effect on the site's operation, especially its scanning capabilities. Equally Kinsta uses load balancers with Google Cloud Platform, blocking IPs wouldn't ever piece of work every bit intended.

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

Corrupted WordPress Database

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

Repairing a corrupted WordPress database depends on the problem. Plugins similar WP-DBManager go far like shooting fish in a barrel to diagnose database issues and repair them. I recommend yous to read Kinsta'south detailed walkthrough on repairing WordPress database issues to go started.

Check Your Site's Plugins and Themes

In nigh cases, third-party plugins and themes don't cause 504 errors. But there'south a slight chance that they might crusade server timeouts, usually by queuing up many uncached requests generated by the plugin/theme. Equally this ties up a lot of your server'south PHP workers, it tin cause 504 errors.

A bang-up example of this event 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. Recollect, you won't lose any information if you but conciliate a plugin.

If you tin access your admin dashboard, you tin can get to the Plugins screen, select Deactivate from the majority actions menu, checkmark all the plugins, and and then hit the Utilise button. This volition disable all of your plugins.

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

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

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

Finally, make sure that your plugins, themes, and WordPress cadre are up to appointment. Also, ensure that your server is running the recommended version of PHP.

If y'all feel this to be likewise overwhelming, you can ever attain out to your host for assistance. Kinsta uses Kinsta APM and other troubleshooting techniques to aid clients narrow downwards what plugin, query, or script might cause the error.

In the worst-case scenarios, like an inefficient query or bad lawmaking in a plugin/theme, you can bring in a WordPress programmer to set up the issue.

Cheque Error Logs

Viewing mistake logs can be very helpful when troubleshooting and debugging 504 errors on your WordPress site. This can help you lot narrow downwards an outcome on your site quickly, especially if it'south resulting from a demanding 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 error logs inside the MyKinsta dashboard

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

          define( 'WP_DEBUG', true ); define( 'WP_DEBUG_LOG', true ); define( 'WP_DEBUG_DISPLAY', simulated );        

The WP_DEBUG constant enables or disables the WordPress debug mode. It has two optional companion constants that can extend its features. The WP_DEBUG_LOG constant directs all errors to be saved to a debug.log file within the /wp-content/ directory. If you don't see this file, you can ever create one.

The WP_DEBUG_DISPLAY constant controls whether debug logs show up on the HTML page. Setting this to false will hide all errors, but yous can review the errors subsequently, as you've also defined WP_DEBUG_LOG as true.

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

Y'all tin can also download the raw WordPress mistake log files via SFTP. Typically, you can discover mistake logs in your server'due south root directory in a folder named "logs."

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

Kinsta users tin also enable WordPress debug manner from their MyKinsta dashboard. To do that, navigate to Sites > Tools > WordPress Debugging and click the Enable push. This will allow y'all to see PHP errors and notices without enabling debug mode via SSH or SFTP.

Lastly, you 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/error.log/

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

Configure Apache or Nginx Settings Properly

You can edit your server config files to increase resources limits for specific directives. This can help you resolve the 504 Gateway Timeout error.

For Apache Webservers

Get-go, add together the post-obit code to your httpd.conf:

          TimeOut 600        

This setting defines how long the server will look for certain requests before marking information technology as a network timeout consequence. Its default value is lx seconds (Apache 2.4 version).

Yous can only add this directive in your httpd.conf file, non in your .htaccess file. Since most shared hosting providers don't allow you to change the httpd.conf file, you can effort increasing the value of the LimitRequestBody directive in your .htaccess file instead.

Then add the post-obit line to your php.ini file:

          max_execution_time 300        

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

For Nginx Webservers

If yous're running your WordPress sites on Nginx + FastCGI Process Manager (PHP-FPM) or using Nginx as a reverse proxy for Apache, you can tweak the server settings to help foreclose 504 Gateway Timeout errors.

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

First, yous must edit your PHP-FPM puddle config file. You tin can find information technology 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 can run the following command in your final to edit the PHP-FPM pool config file:

          sudo nano /etc/php/7.2/fpm/pool.d/www.conf        

Side by side, set the following directive:

          request_terminate_timeout = 300        

Afterwards this, you must edit your php.ini file. You can locate information technology at /etc/php.ini. Open up the file and add/alter 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's location block:

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

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

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

The exact code to reload PHP-FPM will vary based on the PHP version installed on your server. Test your site to see whether information technology has fixed the event.

504 Gateway Timeout Error on Nginx Proxy

If y'all're using Nginx as a reverse proxy server for Apache, and so you can brand information technology 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 Like 504 Gateway Timeout

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

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

Other HTTP errors caused due to client-side issues, like the 404 Non Found error, are also like the 504 mistake. You can refer to Kinsta's detailed guide and list of HTTP status codes for more data.

When you lot don't know what caused a 504 Gateway Timeout error, how practise you fix it in time to go along hard-earned visitors from bouncing to competitor sites? 🤷‍♂️ All the details are in this mail service. ⬆️ Click to Tweet

Summary

Your WordPress site can be affected by the 504 Gateway Timeout error because of multiple reasons. In this article, yous learned how to troubleshoot them all. Typically, these errors are caused due to server-side issues, in which case you can reach out to your host and become it resolved quickly.

Nevertheless, you must also sympathise that this error can be due to 3rd-party plugins, themes, services, inefficient database queries, or a combination of 2 or more of these. If yous're maxing out your server's resources (e.1000. PHP workers), it's recommended to optimize your site for performance.

If you lot nonetheless notice that your website is timing out, then it might very well be that you need to upgrade your hosting programme or the number of PHP workers. I recommend yous to consider this option only afterwards y'all've wearied all the other solutions described in this article.

From simple static sites to complex ecommerce and membership sites, Kinsta's scalable hosting plans are designed to suit all types of websites. To learn more near our scalable deject hosting, cheque out this article!

Did we miss anything? If you're still finding it difficult to fix the 504 Gateway Timeout error on your WordPress site, leave a comment beneath.


Save time, costs and maximize site operation with:

  • Instant assistance from WordPress hosting experts, 24/7.
  • Cloudflare Enterprise integration.
  • Global audition reach with 29 data centers worldwide.
  • Optimization with our born Application Performance Monitoring.

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