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

As the 504 Gateway Timeout error doesn't tell you why it occurred, information technology's hard to pinpoint what's causing the server timeout. This article will help you sympathise it in detail, learn how to diagnose its cause, and and then set it.

Afterwards trying all the various solutions mentioned in the postal service, your site should be up and running in no fourth dimension.

Sounds interesting? Let'due south dive in!

Prefer to watch the video version?

The 504 Gateway Timeout error is one of the most common HTTP 5xx errors faced by website owners and site visitors. 🤔 Acquire how to ready information technology with this guide rapidly. ⬇️ Click to Tweet

What Is the 504 Gateway Timeout Error?

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

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

The server response includes one of many HTTP status codes to indicate the response's condition 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 form of HTTP status codes indicates that something'due south wrong with the server, the server is aware of it, and it cannot carry out the client request. Every bit a result, they're besides referred to equally Server Fault 5xx status codes.

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

The Net Engineering Task 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 it needed to access in gild to complete the request.

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

The 504 Gateway Timeout mistake manifests itself in various forms. Here are some ways it usually 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 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 Error

The browser displays whatsoever 504 Gateway Timeout mistake inside it, just like any other fault. As in that location are various operating systems, web servers, browsers, and user agents, it can testify up in multiple ways.

Below are a few common 504 error message variations that you may meet:

  • 504 Gateway Timeout
  • 504 Gateway Timeout NGINX
  • NGINX 504 Gateway Timeout
  • Gateway Timeout Error
  • Mistake 504
  • HTTP Error 504
  • HTTP Error 504 — Gateway Timeout
  • HTTP 504
  • 504 Error
  • Gateway Timeout (504)
  • This page isn't working — Domain took too long to reply
  • 504 Gateway Time-out — The server didn't respond in fourth dimension
  • The page asking was canceled because it took too long to complete
  • Site visitors: At that place was an consequence serving your asking, please try again in a few minutes.
  • Site Owners: There was a gateway timeout. You should visit your error log for more data.
  • A blank white screen

All the in a higher place error responses, though worded differently, signal to the same 504 Gateway Timeout server error.

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

GitHub's customized HTTP 504 error page
GitHub'due south customized HTTP 504 mistake folio.

SEO Affect of the 504 Gateway Timeout Error

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

For example, when Google spiders stumble upon a 503 Service Unavailable mistake, they'll understand that information technology'due south a temporary event equally it'south mostly used to enable site maintenance mode. Thus, they'll endeavor to crawl the page once more later.

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

Just if your site is down for 6+ hours or more, so Google will consider the 504 error as a serious site-wide event that yous need to ready as soon every bit possible. This can bear on your SEO negatively.

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

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

Causes of the 504 Gateway Timeout Error

As the 504 error is due to a timeout betwixt servers, the trouble probably isn't with the client'south device or cyberspace connection. That also includes your device and connection.

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

The other server demand not e'er exist external (east.yard. CDN, API gateway). It can as well be a server-like entity within the main spider web server (e.thousand. reverse proxy server, database server).

How to Fix the 504 Gateway Timeout Error

Without knowing verbal details about the WordPress site, such as its server configuration, hosting plan, third-party plugins, and the traffic it attracts, you lot may detect it frustrating and overwhelming to set up a 504 Gateway Timeout mistake.

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

Endeavour Reloading the Webpage

One of the first things you can try when encountering a 504 Gateway Timeout error is to look a few minutes and attempt reloading the folio.

Y'all 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 printing the CTRL+F5 shortcut philharmonic instead.

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

While you're at information technology, you can also effort loading the site in a unlike browser to rule that out as an event. As virtually 504 errors are due to temporarily overloaded servers, using this solution should brand your site come up correct dorsum.

If waiting and reloading the site doesn't prepare the 504 error issue, you can cheque whether a site is down for everyone or just y'all. Two useful online tools to examination a site for downtime are Down for Anybody or Just Me and Is It Down Right Now?

Testing Kinsta.com on Down for Everyone or Just Me
Testing Kinsta.com on Downwardly for Everyone or Just 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 help you with fixing the trouble.

While you lot can switch off all these networking devices in any order, the order yous switch them back on is of import. Typically, turn these devices on from the "outside-in," following the connectedness lodge from the cyberspace service provider to your main client device.

Cheque Your Proxy Settings

A proxy server sits between your device and the cyberspace. Information technology'due south mostly used to enhance online privacy past hiding private data (due east.k. device location) from websites and webservers (e.k. using a VPN).

While it's rare for proxy servers to crusade a 504 error, incorrect proxy server settings can sometimes be the reason. Y'all can disable the proxy server and effort reloading the webpage to see whether it'll fix the error.

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

Near clients don't use a proxy service, so you can skip this step if you're confident that yous don't use whatsoever proxy server. Yet, y'all might accept set it without you even knowing nearly it. I'd suggest you check your device's and browser's proxy settings to rule this cause out.

DNS Issues

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

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

You can use free tools similar whatsmydns.net DNS Checker or DNSMap to encounter 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 customer-side DNS issues, you could attempt flushing your local DNS enshroud. Information technology's similar clearing your browser cache, except hither, y'all're flushing the DNS cache from the operating arrangement.

If yous're using Windows, you tin flush the DNS cache by opening the Command Prompt and inbound the post-obit directive:

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

You should see a "Successfully flushed the DNS resolver Enshroud." message if it worked.

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

          sudo killall -HUP mDNSResponder        

You won't meet any notification in macOS when the process finishes, but you 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 control you lot need to enter varies based on which version of macOS you're running. For more details, you tin can refer to the macOS department in Kinsta's in-depth affluent DNS tutorial.

If you lot're using the Linux operating system, 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 control you demand to run may vary from 1 distro to some other. You tin cheque out Kinsta's guide for more than information.

Finally, you tin modify your client-side DNS servers temporarily. Past default, your Isp assigns the DNS servers automatically to you. But you can modify these to public DNS IPs temporarily.

Some reliable DNS servers y'all tin can endeavour out are Google Public DNS, Cloudflare 1.1.ane.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 issue could also be with your content commitment network (CDN). If a site'due south origin server isn't reachable, most CDNs volition try to serve the full webpage from their enshroud.

But virtually CDNs don't enable this feature past default equally it's complex to cache dynamic assets on most sites (eastward.g. the WordPress admin dashboard).

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

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

The same goes for using any other plugin you may utilize to connect to your CDN (e.g. WP Rocket, Breeze, W3 Total Enshroud).

If yous tin't access your site's admin dashboard, you can disable the plugin via SFTP by renaming the plugin's folder proper name.

Disable all plugins via SFTP by renaming the plugins folder name
Disable all plugins via SFTP by renaming the plugins binder proper name

CDNs like Cloudflare or Sucuri, which provide full proxy services, take extra firewalls between their edge servers and your origin server. Hence, you may encounter HTTP 5xx errors more oftentimes while using them. Most of them enshroud 5xx errors returned by your origin server, so it's like shooting fish in a barrel to troubleshoot them.

Cloudflare's costless plan is prone to throw upward a 5xx error. Unfortunately, since it's a total proxy service, there's no quick way to disable information technology. But earlier yous 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 yous 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 outcome lies with your web server and not Cloudflare. You lot tin can try fixing information technology with the other solutions mentioned below or contact your hosting provider's support for technical help.

504 Gateway Timeout at Cloudflare (Variation ii)

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

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

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

Well-nigh probable, Cloudflare is already enlightened of the issue and is working on a gear up already. Y'all can confirm this by checking the Cloudflare System Condition webpage. Alternatively, y'all can get in touch with Cloudflare support for a quicker resolution.

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

504 Gateway Timeout at Cloudflare Due to Large Uploads

The size of your uploads to your site can also exist a reason for the server timeouts. Cloudflare limits upload file size (per HTTP Mail service asking) to just 100 MB on both Costless and Pro plans.

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

The event can be on your host'south end or with Cloudflare. You can notice 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 costless plugin and excluding critical URLs from caching (such as the WordPress admin dashboard). You can refer to Kinsta's detailed mail service on how to configure Cloudflare settings for WordPress.

Suggested reading: How to Gear up Cloudflare APO for WordPress.

Server Issues (Check With Your Host)

Server issues are one of the most common reasons for facing a 504 Gateway Timeout fault. 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 trouble they're facing at other WordPress hosts. The conversation goes something like this:

We're getting around 100k visitors per month with more 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 we were likewise advised that we 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 because of server overload every bit they generate many uncacheable requests. Still, this effect can crop with any site, including unproblematic blogs. Many hosts volition ask you to upgrade to a loftier-tier plan to gear up the issue, which in most cases is unnecessary.

Subscribe Now

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 information technology (Linux, Nginx, PHP, MySQL). The resources are 100% private and aren't shared with any other site, even your sites.

Most WordPress hosts providing shared hosting plans don't accept this adequacy. Hence, a high-traffic site hosted on the same server every bit yours may cause your site to throw up a 504 error likewise.

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

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

A 212.5% increase in performance after switching to C2.
A 212.5% increment in performance after switching to C2.

An overloaded server isn't the just crusade for a server timeout. There can be many other reasons for the 504 error:

Irksome Server Infrastructure

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

The server simply hangs up trying to serve the website. The simply solution to this problem is to upgrade to a server with better infrastructure. For this reason, even Kinsta'south near basic WordPress hosting plan will handle a static site with medium traffic.

Needs More PHP Workers

PHP workers are used to execute your WordPress site'southward code. An ecommerce site that gets l,000 visitors per month needs a lot more than resources than a elementary weblog with the aforementioned amount of traffic. If all the server's PHP workers are busy, they'll build up a queue.

When the queue gets too big, the server disregards erstwhile requests, which may cause the server to throw upwards a 504 gateway mistake. You tin can ask your host almost increasing your number of PHP workers. This'll let your site to execute multiple requests simultaneously.

Firewall Issues

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

Network Connectivity Problems

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 also be network connectivity bug with it.

HTTP Timeouts

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

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

Important: 504 Gateway Timeout errors look like to 503 Service Unavailable errors or 502 Bad Gateway errors. But they're all different. If you lot're experiencing a 504 fault at Kinsta, open a support ticket to get your issue fixed immediately.

For monitoring your site's reanimation on your ain, y'all can apply a tool like updown.io. It'll check your website's status (or any URL) periodically by sending an HTTP request to it. You can ready the cheque frequency from 15 seconds to 1 hour. If your website isn't responding correctly, it'll notify you with an electronic mail or an SMS.

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

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

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

Monitoring your website will give y'all an thought of how oft it'due south downwards. This is especially helpful if yous're using a shared hosting provider. Near managed WordPress hosts have intendance of this automatically for you lot. Hence information technology's always recommended to get with them.

For a detailed explanation, check out Kinsta's post on the importance of managed WordPress hosting.

Spam, Bots, or DDoS Attacks

Malicious attackers can bring your web server to a crawl by sending as well many and/or resource-intensive requests. If your site is getting spammed by bots or undergoing a DDoS assault, information technology tin can overwhelm your server and result in 504 Gateway Timeout errors for many 18-carat users.

You tin look at your server traffic and analytics to see if you can spot any irregular patterns in the site traffic. If you're using Kinsta to host your site, you can view this information easily past going to your MyKinsta Analytics dashboard.

MyKinsta Analytics dashboard
MyKinsta Analytics dashboard

Start your investigation by looking at the elevation client IPs. Information technology'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 will come in super handy.

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

Next, you can bank check out the Cache Analysis study. Here, you tin can run into how many requests are bypassing or missing the cache, or being served from the cache. For performance and stability reasons, you want to cache equally many requests as possible, but it's not always possible to reach that.

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

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

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

Depending upon the length and scale of the attack, this could be a never-ending process of blacklisting IPs as many attackers change their IPs and proxy addresses afterward getting blocked.

Note: Kinsta doesn't permit its clients to install WordPress security plugins as they can have a huge effect on the site's performance, especially its scanning capabilities. Every bit Kinsta uses load balancers with Google Cloud Platform, blocking IPs wouldn't ever work as intended.

You tin apply dedicated security solutions such as Cloudflare or Sucuri to protect your sites from DDoS attacks and spambots. For more than, y'all 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 fault tin can be considering of a decadent database, specially in WordPress sites. Typically, this is due to corrupted database tables or files. Sometimes, it can besides be caused by a serious security issue like your site or database being hacked.

Repairing a corrupted WordPress database depends on the problem. Plugins like WP-DBManager brand it easy to diagnose database issues and repair them. I recommend you to read Kinsta'south detailed walkthrough on repairing WordPress database issues to become started.

Check Your Site's Plugins and Themes

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

A groovy example of this issue is WooCommerce, a plugin installed to add together ecommerce functionality to WordPress sites.

The simplest fashion y'all can troubleshoot this trouble is by deactivating all your plugins. Remember, you won't lose any data if y'all just deactivate a plugin.

If yous can access your admin dashboard, you can go to the Plugins screen, select Deactivate from the bulk actions menu, checkmark all the plugins, and then hit the Utilise button. This will disable all of your plugins.

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

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

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

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

If you experience this to be too overwhelming, you tin can always reach out to your host for aid. Kinsta uses Kinsta APM and other troubleshooting techniques to help clients narrow down what plugin, query, or script might cause 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 ready the consequence.

Check Mistake Logs

Viewing mistake logs can be very helpful when troubleshooting and debugging 504 errors on your WordPress site. This can help you narrow down an event on your site quickly, specially if it'south resulting from a demanding plugin on your site.

If yous're a Kinsta client, you tin easily see errors in the log viewer in your MyKinsta dashboard.

Checking error logs inside MyKinsta dashboard
Checking fault logs within the MyKinsta dashboard

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

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

The WP_DEBUG constant enables or disables the WordPress debug manner. It has ii 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 tin can e'er create 1.

The WP_DEBUG_DISPLAY constant controls whether debug logs bear witness upwards on the HTML page. Setting this to false will hide all errors, merely you can review the errors later on, as you've also defined WP_DEBUG_LOG equally truthful.

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

You can also download the raw WordPress mistake log files via SFTP. Typically, you lot can 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 folder via SFTP

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

Lastly, y'all can check the server log files. Depending on which server y'all're using to host your WordPress site, they're normally 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 data.

Configure Apache or Nginx Settings Properly

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

For Apache Webservers

Beginning, add the following lawmaking to your httpd.conf:

          TimeOut 600        

This setting defines how long the server will wait for certain requests before marking information technology every bit a network timeout event. Its default value is sixty seconds (Apache 2.4 version).

You can only add this directive in your httpd.conf file, not in your .htaccess file. Since most shared hosting providers don't let you to change the httpd.conf file, y'all tin can 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'south max_execution_time directive is thirty 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 Procedure Manager (PHP-FPM) or using Nginx equally 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, y'all must edit your PHP-FPM pool config file. You can find information technology at the /etc/php7.4/fpm/puddle.d/world wide web.conf location in your Nginx server (the verbal path may vary based on the PHP version). Alternately, yous tin run the post-obit command in your terminal to edit the PHP-FPM puddle config file:

          sudo nano /etc/php/vii.two/fpm/pool.d/www.conf        

Adjacent, set the following directive:

          request_terminate_timeout = 300        

Later on this, you must edit your php.ini file. You can locate it at /etc/php.ini. Open up the file and add/change the value for the max_execution_time directive to 300 seconds.

          max_execution_time = 300        

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

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

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

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

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

504 Gateway Timeout Fault on Nginx Proxy

If you're using Nginx equally a contrary proxy server for Apache, and so you can brand it more than lenient towards server timeouts by calculation 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

Equally mentioned earlier in the commodity, many other HTTP 5xx errors are simply similar the 504 Gateway Timeout error. Information technology's because they all happen on the server-side. These errors include:

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

Other HTTP errors caused due to client-side issues, like the 404 Not Institute mistake, are too similar the 504 fault. You can 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 exercise you lot set up information technology in time to go along hard-earned visitors from bouncing to competitor sites? 🤷‍♂️ All the details are in this post. ⬆️ Click to Tweet

Summary

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

However, you must also understand that this error can be due to tertiary-political 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.g. PHP workers), it's recommended to optimize your site for operation.

If you still find that your website is timing out, then it might very well be that you lot need to upgrade your hosting plan or the number of PHP workers. I recommend y'all to consider this choice just later on you've exhausted 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 conform all types of websites. To acquire more nearly our scalable cloud hosting, check out this article!

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


Save fourth dimension, costs and maximize site operation with:

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

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