The 504 Gateway Timeout mistake is one of the well-nigh common HTTP 5xx errors faced by 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 billowy to competitor sites.

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

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

Sounds interesting? Let'due south dive in!

Prefer to watch the video version?

The 504 Gateway Timeout fault is i of the virtually common HTTP 5xx errors faced by website owners and site visitors. 🤔 Learn how to gear up it with this guide quickly. ⬇️ Click to Tweet

What Is the 504 Gateway Timeout Error?

Every time yous 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'due south status to the browser. Only non 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 grade of HTTP status codes indicates that something's wrong with the server, the server is enlightened of information technology, and it cannot carry out the client asking. As a result, they're also referred to as Server Error 5xx status codes.

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

The Cyberspace Technology Chore Force (IETF) defines the 504 Gateway Timeout mistake as:

The 504 (Gateway Timeout) status lawmaking 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 get-go server (typically the chief server) times out, waiting for a response from the 2nd server (upstream server).

The 504 Gateway Timeout error manifests itself in various forms. Here are some means 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 2nd 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 Fault

The browser displays any 504 Gateway Timeout mistake inside it, just like any other fault. As there are various operating systems, web servers, browsers, and user agents, information technology tin can show upwards in multiple ways.

Below are a few mutual 504 error bulletin variations that yous may encounter:

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

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

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

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

SEO Impact of the 504 Gateway Timeout Error

All 5xx errors foreclose a webpage from loading, making them detrimental to user feel. Hence, search engines like Google take these errors seriously. If the error persists for a long duration, information technology may even atomic number 82 to deindexing the webpage from the search engine results.

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

A 504 Gateway Timeout error isn't necessarily temporary as 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 minute, they'll endeavour to serve the page from their enshroud.  They wouldn't even notice it.

But if your site is down for half-dozen+ hours or more, and then Google will consider the 504 error as a serious site-wide issue that you need to fix as before long 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 Console is one 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'southward device or internet connection. That also includes your device and connexion.

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

The other server demand non always exist external (e.g. CDN, API gateway). Information technology can also be a server-similar entity within the master web server (east.g. reverse proxy server, database server).

How to Fix the 504 Gateway Timeout Error

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

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

Try Reloading the Webpage

1 of the first things you lot can try when encountering a 504 Gateway Timeout fault is to await a few minutes and try reloading the page.

You can press the F5 keyboard shortcut to refresh/reload the webpage in nigh 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, you lot tin can as well try loading the site in a unlike browser to rule that out as an event. As well-nigh 504 errors are due to temporarily overloaded servers, using this solution should make your site come right back.

If waiting and reloading the site doesn't fix the 504 fault issue, y'all tin cheque whether a site is down for everyone or just you. Ii useful online tools to test a site for downtime 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 Downwards for Everyone or Merely Me

Reboot Your Network Devices

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

While y'all can switch off all these networking devices in any club, the order you switch them back on is of import. Typically, turn these devices on from the "exterior-in," post-obit the connection order from the isp to your main client device.

Check Your Proxy Settings

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

While it's rare for proxy servers to cause a 504 error, incorrect proxy server settings tin sometimes be the reason. You tin disable the proxy server and try reloading the webpage to run into whether it'll ready the error.

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

Most clients don't employ a proxy service, and so you tin skip this step if you're confident that you don't utilize any proxy server. However, you might have prepare it without you lot even knowing nearly it. I'd suggest you cheque your device's and browser'southward proxy settings to rule this cause out.

DNS Bug

A 504 Gateway Timeout mistake can too be acquired by DNS issues on the server-side or the customer-side (or both).

The most probable reason for a server-side DNS issue is the FQDN (fully qualified domain name) non resolving the right IP accost or the DNS server non responding. Usually, this occurs when you've but migrated your WordPress site to a new server or host. Hence, it's important to expect for the domain's DNS records to propagate fully, which can accept up to 24 hours.

Y'all can employ free tools like whatsmydns.cyberspace DNS Checker or DNSMap to run into if your DNS has propagated around the earth.

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

For fixing client-side DNS issues, you could try flushing your local DNS cache. It's similar clearing your browser cache, except here, you're flushing the DNS cache from the operating organisation.

If you're using Windows, you tin can flush 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 Control Prompt in Windows

Yous should see a "Successfully flushed the DNS resolver Cache." message if it worked.

For the latest macOS versions, y'all tin can open the Terminal and run the post-obit command:

          sudo killall -HUP mDNSResponder        

Y'all 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 you're running. For more details, y'all can refer to the macOS section in Kinsta's in-depth affluent DNS tutorial.

If y'all're using the Linux operating system, then the process is quite similar to macOS equally fifty-fifty Linux uses the Terminal as its control-line interface. Since there are many Linux distributions, the verbal command y'all need to run may vary from ane distro to some other. Y'all tin can check out Kinsta's guide for more information.

Finally, yous can change your client-side DNS servers temporarily. By 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 attempt out are Google Public DNS, Cloudflare 1.1.1.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 be with your content delivery network (CDN). If a site's origin server isn't reachable, near CDNs will try to serve the full webpage from their cache.

Merely most CDNs don't enable this characteristic by default as it'south complex to cache dynamic assets on virtually sites (due east.g. 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 avails to the CDN URLs, then you can deactivate the plugin and examination reloading your site.

The same goes for using any other plugin you may use to connect to your CDN (due east.m. WP Rocket, Breeze, W3 Total Enshroud).

If yous can't admission your site's admin dashboard, y'all tin can disable the plugin via SFTP by renaming the plugin's binder 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 full proxy services, have extra firewalls betwixt their edge servers and your origin server. Hence, you may encounter HTTP 5xx errors more oftentimes while using them. Almost of them enshroud 5xx errors returned by your origin server, and then it's easy to troubleshoot them.

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

504 Gateway Timeout at Cloudflare (Variation 1)

Cloudflare will show 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'south custom Error 504 screen

Hither, the issue lies with your spider web server and non Cloudflare. You can try fixing it with the other solutions mentioned below or contact your hosting provider'southward support for technical help.

504 Gateway Timeout at Cloudflare (Variation ii)

If Cloudflare causes the 504 Gateway Timeout fault, the error screen will mention "cloudflare," which is currently the standard server proper name for all Cloudflare assets. Usually, the error screen will appear as 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 whatever Cloudflare-branded fault screen here.

Virtually likely, Cloudflare is already enlightened of the issue and is working on a fix already. You can confirm this past checking the Cloudflare Organisation Status webpage. Alternatively, you can arrive impact with Cloudflare support for a quicker resolution.

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

504 Gateway Timeout at Cloudflare Due to Large 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 POST asking) to just 100 MB on both Complimentary and Pro plans.

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

The issue can exist on your host'southward terminate or with Cloudflare. You tin discover 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 post on how to configure Cloudflare settings for WordPress.

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

Server Bug (Check With Your Host)

Server problems are one of the most 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 calendar month with more than than 200k views. Currently, we're hosting with ____ and we experience 504 errors constantly due to server overload. I don't like how ____ handled the problem, and nosotros were too advised that we will have to movement to their defended plans before long, which I believe is not necessary.

High-traffic and ecommerce sites are more prone to getting 504 errors because of server overload equally they generate many uncacheable requests. All the same, this outcome tin can crop with whatever site, including simple blogs. Many hosts will ask you to upgrade to a high-tier programme to fix 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.

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 up a 504 mistake too.

Autonomously 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 ways 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.v% increment in performance after switching to C2.

An overloaded server isn't the only cause for a server timeout. In that location tin exist many other reasons for the 504 error:

Slow Server Infrastructure

The server y'all use to host your WordPress site may not have enough resources to handle the load. Information technology's similar playing a modern, graphics-intensive videogame on a decade-old PC.

The server just hangs upwards trying to serve the website. The only solution to this problem is to upgrade to a server with better infrastructure. For this reason, fifty-fifty Kinsta's most basic WordPress hosting plan volition handle a static site with medium traffic.

Needs More PHP Workers

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

When the queue gets also big, the server disregards old requests, which may cause the server to throw up a 504 gateway fault. Y'all can inquire your host about increasing your number of PHP workers. This'll let your site to execute multiple requests simultaneously.

Firewall Bug

Your server's firewall could take some errors or an improper configuration. Possibly, a few of its rules foreclose the server from establishing a connection properly. To know if your firewall is the culprit, y'all can check your server'southward error logs.

Network Connectivity Problems

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

HTTP Timeouts

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

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

Of import: 504 Gateway Timeout errors look similar to 503 Service Unavailable errors or 502 Bad Gateway errors. Just they're all different. If you're experiencing a 504 fault at Kinsta, open a back up ticket to get your outcome stock-still immediately.

For monitoring your site's downtime on your own, you tin utilize a tool like updown.io. It'll cheque your website'south condition (or any URL) periodically past sending an HTTP asking to it. You tin set the check frequency from 15 seconds to 1 hour. If your website isn't responding correctly, it'll notify you lot with an e-mail 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 business relationship of updown.io, merely if you're looking for cheaper alternatives, you can check out WebGazer or UptimeRobot. Both these tools will help y'all monitor your site's uptime every 5 minutes for free. That's decent enough for almost website owners.

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

Monitoring your website will give you an idea of how often it's down. This is especially helpful if you lot're using a shared hosting provider. Almost managed WordPress hosts have care of this automatically for y'all. Hence it's always recommended to go with them.

For a detailed explanation, check out Kinsta's mail 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 too many and/or resource-intensive requests. If your site is getting spammed by bots or undergoing a DDoS set on, information technology can overwhelm your server and result in 504 Gateway Timeout errors for many 18-carat users.

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

MyKinsta Analytics dashboard
MyKinsta Analytics dashboard

Start your investigation past looking at the pinnacle customer IPs. It'll requite y'all 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, so this report will come 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 study. Hither, you can encounter how many requests are bypassing or missing the enshroud, or beingness served from the enshroud. For operation and stability reasons, you desire to cache as many requests as possible, but it's not always possible to achieve that.

For example, WooCommerce sites generate many uncacheable requests for features such every bit 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 beef up your website's security by spotting and blocking worrisome traffic/IPs. Y'all can inquire your host to block certain IPs too.

Depending upon the length and calibration of the set on, this could exist a never-ending process of blacklisting IPs every bit many attackers change their IPs and proxy addresses later getting blocked.

Note: Kinsta doesn't permit its clients to install WordPress security plugins as they can take a huge result on the site's performance, especially its scanning capabilities. Equally Kinsta uses load balancers with Google Deject Platform, blocking IPs wouldn't always work every bit intended.

Y'all can use defended security solutions such as Cloudflare or Sucuri to protect your sites from DDoS attacks and spambots. For more, you tin 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 tin can be because of a corrupt database, especially in WordPress sites. Typically, this is due to corrupted database tables or files. Sometimes, it tin can too be caused by a serious security outcome 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 y'all to read Kinsta's detailed walkthrough on repairing WordPress database issues to get started.

Bank check Your Site's Plugins and Themes

In almost cases, 3rd-party plugins and themes don't cause 504 errors. But at that place'south a slight take a chance that they might crusade server timeouts, usually by queuing up many uncached requests generated past the plugin/theme. As this ties upwards a lot of your server'south PHP workers, it can cause 504 errors.

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

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

If you can access your admin dashboard, you can go to the Plugins screen, select Conciliate from the bulk actions card, 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 you can't admission your admin area, you can disable plugins via SFTP using the method described before. Just rename the main plugin binder proper noun to disable all the plugins in bulk.

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

Finally, brand certain that your plugins, themes, and WordPress core are up to date. Besides, ensure that your server is running the recommended version of PHP.

If you feel this to be too overwhelming, you can ever reach out to your host for help. 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-instance scenarios, like an inefficient query or bad lawmaking in a plugin/theme, you can bring in a WordPress developer to fix the event.

Check Error Logs

Viewing fault logs can exist very helpful when troubleshooting and debugging 504 errors on your WordPress site. This tin can help you lot narrow downwardly an issue on your site quickly, especially if information technology'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 error logs inside the MyKinsta dashboard

If your host doesn't accept a logging tool, and then you can enable WordPress debug mode by adding the post-obit lawmaking to your wp-config.php file:

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

The WP_DEBUG abiding enables or disables the WordPress debug mode. It has 2 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 yous don't see this file, you can e'er create one.

The WP_DEBUG_DISPLAY constant controls whether debug logs evidence upward on the HTML page. Setting this to false will hide all errors, but yous tin can review the errors later, as you've also defined WP_DEBUG_LOG as truthful.

Important: If you have WP_DEBUG enabled in the Kinsta environment, it'll route all errors to the debug.log file and not the error.log in the MyKinsta dashboard.

You can likewise download the raw WordPress error log files via SFTP. Typically, you tin can notice 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 besides enable WordPress debug mode from their MyKinsta dashboard. To do that, navigate to Sites > Tools > WordPress Debugging and click the Enable push button. This will allow you to see PHP errors and notices without enabling debug mode via SSH or SFTP.

Lastly, yous can check the server log files. Depending on which server yous're using to host your WordPress site, they're commonly plant 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 information.

Configure Apache or Nginx Settings Properly

Yous can edit your server config files to increment resource limits for specific directives. This tin can help you resolve the 504 Gateway Timeout error.

For Apache Webservers

First, add together the following lawmaking to your httpd.conf:

          TimeOut 600        

This setting defines how long the server volition await for certain requests earlier marking it as a network timeout issue. Its default value is sixty seconds (Apache 2.4 version).

You can only add together this directive in your httpd.conf file, not in your .htaccess file. Since most shared hosting providers don't allow you to modify the httpd.conf file, you 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'due south max_execution_time directive is thirty seconds. Increasing it volition permit your site'south PHP scripts to run longer.

For Nginx Webservers

If you'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 assistance preclude 504 Gateway Timeout errors.

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

Outset, you 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 exact path may vary based on the PHP version). Alternately, you can run the following command in your terminal to edit the PHP-FPM puddle config file:

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

Side by side, set the following directive:

          request_terminate_timeout = 300        

Afterwards this, you must edit your php.ini file. Y'all tin locate it at /etc/php.ini. Open the file and add together/alter 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's location cake:

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

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

          sudo service nginx reload sudo service php7.4-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 you're using Nginx as a contrary proxy server for Apache, and then you lot can make information technology more lenient towards server timeouts by adding the post-obit 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 just similar the 504 Gateway Timeout error. It'south because they all happen on the server-side. These errors include:

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

Other HTTP errors acquired due to client-side issues, like the 404 Not Found fault, are besides like the 504 error. You tin refer to Kinsta's detailed guide and list of HTTP condition codes for more information.

When y'all don't know what acquired a 504 Gateway Timeout mistake, how practice you set up it in time to keep hard-earned visitors from bouncing to competitor sites? 🤷‍♂️ All the details are in this post. ⬆️ Click to Tweet

Summary

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

Notwithstanding, you must besides understand that this error tin can be due to third-political party plugins, themes, services, inefficient database queries, or a combination of two or more of these. If you're maxing out your server's resources (east.g. PHP workers), it'due south recommended to optimize your site for functioning.

If you still detect that your website is timing out, and so it might very well be that you lot need to upgrade your hosting programme or the number of PHP workers. I recommend you to consider this choice only after you've wearied all the other solutions described in this commodity.

From simple static sites to circuitous ecommerce and membership sites, Kinsta's scalable hosting plans are designed to suit all types of websites. To larn more about our scalable cloud hosting, bank check 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, go out a comment below.


Save fourth dimension, costs and maximize site performance with:

  • Instant help from WordPress hosting experts, 24/7.
  • Cloudflare Enterprise integration.
  • Global audience reach with 32 information centers worldwide.
  • Optimization with our built-in Awarding Performance Monitoring.

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