Key Takeaways
- The 504 error happens when a proxy server waits too long to get a response from an upstream server and eventually drops the connection.
- Website owners must check their server timeout limits and PHP execution times to fix the root cause of the error.
- Everyday visitors can often bypass this error by hard refreshing their browser or toggling a VPN to clear local network blocks.
Seeing a 504 Gateway Timeout error on a website can be stressful. It blocks access for visitors, and when they can’t access your site, it can hurt your traffic, and damage SEO.
The frustrating part is, this error does not always come from the same place. Sometimes it’s due to a temporary glitch on a visitor’s network. Other times, it’s due to hosting-level issues or something deeper inside your server setup.
In this guide, I’ll cover fixes for both everyday website visitors and website owners. We’ll look at how to instantly diagnose the root cause using Cloudways Copilot, as well as the traditional manual steps you can take to get your server back online.
- What Is the 504 Gateway Timeout Error?
- How Does the 504 Error Impact SEO?
- 502 Bad Gateway vs. 504 Gateway Timeout
- What Are the Most Common Variations of the 504 Gateway Timeout Error?
- What Causes the 504 Error?
- How to Fix a 504 Gateway Timeout (For Website Owners)
- 1. Automate 504 Diagnostics with Cloudways Copilot
- 2. Adjust Server-Side Timeout Limits (Nginx & Apache)
- 3. Increase PHP Max Execution Time
- 4. Troubleshoot Cloudflare 504 Errors
- 5. Pinpoint Problematic WordPress Plugins or Themes
- 6. Check and Reset the .htaccess File
- 7. Monitor Server Resources and Check Logs
- How to Fix a 504 Gateway Timeout (For Website Visitors)
- How Cloudways Helps Prevent 504 Errors
- Wrapping Up!
What Is the 504 Gateway Timeout Error?
According to the MDN Web Docs definition, a 504 Gateway Timeout is an HTTP status code which means that a server acting as a gateway or proxy, didn’t get a timely response from an upstream server.
In simple English, your browser’s connection usually goes through a middleman, like Nginx, Apache, or Cloudflare, to reach the main server holding the website files.
This main server is called the “upstream server.” If this upstream server is overloaded with traffic or running a slow script, the middleman eventually cuts the connection and displays a 504 error.
How Does the 504 Error Impact SEO?
A 504 gateway timeout error can hurt your rankings in more ways than one. When visitors hit a dead end, they usually leave right away. This drives up bounce rates and tells search engines your site isn’t reliable.
Extended downtime can also block search engine crawlers, leading to missed indexing opportunities. If the issue continues, some pages might even disappear from search results altogether. Over time, search engines may reduce how often they crawl your site.
So, it is highly crucial to promptly address and resolve the 504 error to safeguard your website’s SEO.
502 Bad Gateway vs. 504 Gateway Timeout
502 and 504 are two very similar looking errors, in a sense that they’re both server-side issues. However, they’re different.
Check the table below:
| Error Code | Meaning | What Happened Behind the Scenes |
|---|---|---|
| 502 Bad Gateway | Invalid Response | The upstream server responded, but the intermediary was unable to understand the response. |
| 504 Gateway Timeout | No Response | The upstream server took too long to respond, and the request timed out before a response was received. |
What Are the Most Common Variations of the 504 Gateway Timeout Error?
The 504 Gateway Timeout error can appear differently depending on the browser, the web server, or the operating system you’re using.
No matter the wording you see, these error messages all mean the same thing: the server did not respond quickly enough.
Here are some common variations of the 504 error you may come across:
- Error 504
- HTTP Error 504
- HTTP Error 504 Gateway Timeout
- HTTP 504
- Gateway Timeout Error
- 504 Error
- Gateway Timeout (504)
- 504 Gateway Timeout
- 504 Gateway Timeout NGINX
- NGINX 504 Gateway Timeout
You might run into these errors while browsing, checking a server status page, or reviewing your server logs.
What Causes the 504 Error?
Like I mentioned briefly earlier, a 504 Gateway Timeout error is typically triggered when a server doesn’t get a timely response from another server. Even though this is mostly a server-side issue, some client-side factors can contribute too.
Below are some of the most common reasons this error shows up:
- Upstream server timeout: The main server waited for a response from another server, like a database or API, but the response took too long and timed out.
- Server overload: When a hosting server is under heavy load or running out of resources, it may fail to process requests in time and throw the error
- Faulty PHP scripts: Poorly written or long-running scripts can hang and cause timeouts.
- Firewall or security services: Overly strict firewalls at the host or application level can also block legitimate responses, triggering the error.
- VPN or proxy interference: VPNs and proxies can occasionally disrupt your connection or route traffic incorrectly, preventing the server from responding properly.
- DNS or CDN issues: Sometimes, misconfigured DNS settings or CDN delays can prevent the server from responding on time.
- Server misconfigurations: Incorrect server settings, such as timeout values or buffer limits, can delay responses and trigger connection errors.
- Plugin conflicts: In WordPress sites, a slow or poorly coded plugin can cause delayed response times, especially if it makes external requests.
- Server downtime: If the server you are trying to reach is temporarily unavailable due to maintenance or an outage, it may not respond in time, resulting in a timeout.
Say Goodbye to 504 Timeout Errors with Autonomous
Cloudways Autonomous uses Kubernetes-based autoscaling to instantly handle unexpected traffic surges, ensuring your WordPress site never times out and stays lightning-fast.
How to Fix a 504 Gateway Timeout (For Website Owners)
If you manage a website, you’re the only one who can resolve the root cause of the 504 error. Visitors can’t do anything on their end.
Below I’ve covered some of the most effective server-side fixes to resolve this error.
1. Automate 504 Diagnostics with Cloudways Copilot
Troubleshooting a 504 Gateway Timeout usually means guessing which plugin, database query, or third-party API took too long to execute. If you host on Cloudways, you don’t need to manually check logs or blindly deactivate plugins. Cloudways Copilot combines Server-Level Monitoring and Application-Level Monitoring to automatically detect, investigate, and recommend exact solutions for these timeout issues.
Because a 504 error can be triggered by either a frozen server process or a slow application script, Copilot investigates both layers:
Application-Layer Errors (WordPress & WooCommerce)
To catch the heavy scripts or slow queries that cause the upstream server to time out, Copilot automatically pings your WordPress or WooCommerce homepage every 6 hours.
It specifically watches for the 504 timeout, alongside a complete spectrum of standard server and Cloudflare-edge errors:
Standard Server Errors:
- 500 (Internal Server Error)
- 501 (Not Implemented)
- 502 (Bad Gateway)
- 503 (Service Unavailable)
- 504 (Gateway Timeout)
- 508 (Loop Detected)
- 509 (Bandwidth Limit Exceeded)
- 510 (Not Extended)
Cloudflare-Side Errors:
- 520 (Unknown Error)
- 521 (Web Server Is Down)
- 522 (Connection Timed Out)
- 523 (Origin Is Unreachable)
- 525 (SSL Handshake Failed)
- 526 (Invalid SSL Certificate)
- 530 (Site Frozen / 1xxx Error)
If a 504 status is detected, Copilot triggers a silent internal alert (kept hidden from your inbox to prevent spam). It then runs a 6 to 7-minute automated AI investigation into your logs to find the exact bottleneck.
You then receive a comprehensive AI Insight directly in your email and platform dashboard. This capability is included in all Copilot plans with zero setup required, costing exactly 1 AI credit per Insight.

Every Insight provides:
- An Investigation Summary: A plain-English breakdown explaining exactly what timed out (for example, identifying a specific WooCommerce extension making a slow external API call).
- Actionable Recommendations: Clear, step-by-step instructions on how to safely resolve the delay and restore your site.

Server-Layer Errors
Sometimes a 504 happens because a core service (like PHP-FPM) crashed or your server completely ran out of resources. Copilot tracks these stack metrics 24/7.
For these infrastructure-level faults, Copilot provides SmartFix. Once you review the AI’s proposed action, you can deploy an engineer-tested playbook with a single click (like automatically restarting PHP-FPM) to bring your server back online instantly.

If you aren’t hosting on Cloudways or prefer to hunt down the source of the timeout yourself, continue reading the manual troubleshooting steps below.
2. Adjust Server-Side Timeout Limits (Nginx & Apache)
Since a 504 error is triggered when a server times out after waiting for a response, the most logical first step is to just give it more time to respond.
If your site runs on Nginx, it probably has a strict cutoff time for upstream requests. For example, if a heavy database query takes 60 seconds to process but Nginx is configured to wait only 30 seconds, it will instantly throw the 504 error.
To fix this, you need to open your nginx.conf file and increase the timeout limits. What you’ll need to look for are two specific directives. These are:
- proxy_read_timeout
- fastcgi_read_timeout
Add or update these lines to give the server more time to process requests, like 300 seconds, for example.
proxy_read_timeout 300;
fastcgi_read_timeout 300;
Once you’ve made the changes and saved the file, restart Nginx so the new rules can take effect.
If you are using Apache instead of Nginx, the process is more or less similar. You just need to look for the httpd.conf or apache2.conf file. Then, lookup the Timeout directive and increase the value. By default, the value is set to 60, but you can change it to 300 to match the example I showed you earlier.
Timeout 300
Once done making the change, save the file, restart Apache. This simple tweak is enough to resolve the error most of the time, especially if your site regularly handles large file uploads or runs heavy scripts.
3. Increase PHP Max Execution Time
If your site is running resource-heavy operations like large file uploads, imports, or slow API requests, your server might be hitting PHP’s max_execution_time limit, leading to a 504 error.
To fix this, increase the PHP execution time limit so PHP scripts are allowed to run longer before being cut off.
Ways to increase it:
Via wp-config.php
Add this line near the bottom:
set_time_limit(300);
Via .htaccess
php_value max_execution_time 300
Via php.ini
max_execution_time = 300
4. Troubleshoot Cloudflare 504 Errors
If you use Cloudflare on your site, there’s a good chance you’re seeing a 504 error directly from Cloudflare. That said, Cloudflare has two different 504 error screens. And knowing which one you’re looking at tells, you exactly where the problem is:
- The Cloudflare-branded screen: If the error says something like “the origin web server did not respond to cloudflare“, the issue is on your server. Cloudflare has a default 100-second timeout limit. If your server takes longer than that, Cloudflare throws the error. To fix this, you’ll need to apply the Nginx or PHP timeout fixes I talked about earlier.
- A plain white screen: If you see a text-based 504 error instead of a Cloudflare branded page, the timeout is probably taking place on your origin server’s side and not caused by Cloudflare.
When troubleshooting Cloudflare, a lot of people will advise you to delete your domain from the CDN to see if it fixes the issue. I recommend not doing this. Deleting your CDN exposes your origin IP and removes caching, which can crash a server that is already struggling.
Instead, a safer way to test if Cloudflare is causing the timeout issue is to temporarily bypass it.
Here is how to do it safely:
- Log into your Cloudflare dashboard.
- Select your domain and go to the Overview page.
- Scroll down and find Advanced Actions and click on Pause Cloudflare option.

Pausing Cloudflare temporarily routes traffic directly to your server without deleting your Cloudflare setup. If the site loads fine after pausing Cloudflare, you know your CDN configuration needs to be adjusted.
5. Pinpoint Problematic WordPress Plugins or Themes
One of the most common causes of the 504 error in WordPress sites is a poorly coded plugin or theme. Whether it’s because of heavy resource usage, code conflicts, or outdated scripts, just a single problematic plugin can mess up server communication and cause timeouts.
To figure out if a plugin is causing an issue on your site, go ahead and deactivate all your WordPress plugins and reactivate them one by one to pinpoint the faulty plugin.
In case you have access to the WordPress admin area:
- Go to Plugins > Installed Plugins.
- Then, check the box at the top to select all plugins in one go.
- Next, choose Deactivate from the Bulk Actions dropdown and hit Apply.

- Once all the plugins are deactivated, load your site. If the site loads now without any errors, start reactivating each plugin one at a time. Refresh the site after activating each plugin to figure out exactly which plugin is causing the issue.
- After finding the faulty plugin, go ahead and either delete it, or update it and then test the site again.
If you’re locked out of your WordPress admin dashboard, you can deactivate plugins via FTP, like this:
- Connect to your server using an FTP client like FileZilla.
- Go to the public_html/wp-content.
- Rename the plugins folder to something like plugins-old.

If the site loads fine after renaming the folder, you’ve confirmed that one or more plugins are the problem. Now, rename plugins-old back to plugins and log into your WordPress dashboard.
You’ll now notice all your plugins are deactivated. This happened because we renamed the plugins folder. Activate each plugin manually like the last time and test your site after each update to isolate the faulty plugin.
If deactivating plugins didn’t fix the error, your theme could be the culprit. Poorly coded or outdated themes can cause 504 Gateway Timeout errors due to heavy resource usage.
To test this, switch to a default WordPress theme like Twenty Twenty-Five using your WordPress Dashboard by going to Appearance > Themes.

If you don’t have access to your admin area, you can still switch themes via FTP:
- Go to /wp-content/themes/, and rename your current theme’s folder.
- WordPress will automatically revert to a default theme if one is available.
If your site loads normally after switching, your original theme is likely causing the issue.
6. Check and Reset the .htaccess File
Another common cause for the 504 error in WordPress is a corrupted .htaccess file. If you don’t know, this file controls important server settings and URL rewrite rules that help WordPress route requests correctly.
If a plugin modifies this file incorrectly or a file transfer is interrupted during execution, rules can become corrupted. When that happens, requests may not get processed properly. This can result in timeout errors and other site issues.
The easiest way to check if your .htaccess file is not corrupted is to simply reset it to its default WordPress state.
You can do this by:
- Connecting to your server using an FTP client like FileZilla.
- Look for the .htaccess file in your root folder.

- Rename the file to something like .htaccess_old.
- Create a new text file and name it .htaccess.
- Open the new blank file and paste the default WordPress rewrite rules inside it:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
- Save the file and refresh your website.
If your site loads now, then a corrupted routing rule inside the file was causing the 504 timeout.
7. Monitor Server Resources and Check Logs
Traffic spikes or resource-heavy processes can overwhelm a server, causing it to run out of time and drop the connection.
To figure out if this is what’s happening in your case, check your server error logs. Error logs are great as they can help you find the exact problematic area on your site and debug 504 errors.
If you are a Cloudways customer, you can check your error logs simply by following these steps:
- Go to your Application settings.
- Click on Monitoring in the left-hand menu.
- Select Logs, and then choose Error Logs.

Go through the error logs to see if certain scripts, themes, or plugins are wasting memory space and causing the timeout. This isn’t the only cause, however, it’s entirely possible for a malfunctioning plugin to slow down a server so much that it cannot respond in the expected time.
In addition to the logs, you should also monitor your server’s RAM and CPU usage, which you can also monitor from your Cloudways dashboard.

If you notice your server resources are constantly maxing out during peak traffic hours or when taking backups, you might want to scale up your server size so it has the capacity to handle the load without timing out.
Automate 504 Diagnostics with Cloudways Copilot
Don’t waste time hunting for the bottleneck. Cloudways Copilot pinpoints the exact plugin causing your timeout and delivers 1-Click SmartFixes to bring crashed servers back online.
How to Fix a 504 Gateway Timeout (For Website Visitors)
If you’re just visiting a website and run into a 504 error, there’s not much you can do about it. I say this because almost always, the cause of this error is on the server-side.
This means the issue can only be fixed by the website owner. Usually, your best option is to just wait until the site owner gets the site back online.
However, sometimes local network glitches, outdated cache, or DNS issues on your device can mimic a 504 error. To make sure the problem isn’t on your end, here are a few fixes you can try.
1. Hard Refresh, Clear Cache, and Flush DNS
Before trying anything complicated, just hard refresh. This forces your browser to ignore its cached version of the page and fetch a fresh copy from the server. On Windows, press Ctrl + F5. On a Mac, press Cmd + Shift + R.
If a hard refresh doesn’t work, your operating system or browser might be holding onto stale, corrupted DNS data. Flushing your DNS cache will clear up corrupt data and fix the issue.
Here is how to flush the DNS cache depending on your setup.
macOS
The DNS flush command varies slightly by version of macOS you’re using, but the most widely compatible command is:
sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
To run this command:
- Open Terminal.
- Paste the command and hit Enter.
- Enter your password when prompted.
For specific older versions:
| macOS Version | DNS Flush Command |
|---|---|
| macOS Sierra (10.12) and newer | sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder |
| Yosemite (10.10.4 to 10.10.5) | sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder |
| Yosemite (10.10.0 to 10.10.3) | sudo discoveryutil mdnsflushcache |
| Mavericks, Mountain Lion, Lion | sudo killall -HUP mDNSResponder |
| Snow Leopard | sudo dscacheutil -flushcache |
Linux
DNS caching depends on the service in use. Try the appropriate command below in your terminal.
For systemd-based systems:
sudo resolvectl flush-caches
If using dnsmasq:
sudo systemctl restart dnsmasq
If using nscd:
sudo systemctl restart nscd
Not all distributions of Linux cache DNS by default. If you’re not sure whether yours does, check which DNS service your system is using before clearing cache.
Windows
Flushing the DNS on Windows can be done with just a single command. Here’s how to do this:
- Type cmd in the Windows search bar.
- Open Command Prompt, paste the following command and press Enter:
ipconfig /flushdns

- You should now see a confirmation saying, “Successfully flushed the DNS Resolver Cache.“
If you prefer using Windows PowerShell instead of the Command Prompt, you can open PowerShell and run this command instead:
Clear-DnsClientCache
(Optional) Browser-Level DNS
Modern browsers like Chrome and Firefox cache DNS separately from your operating system. If you’re on Chrome, you can manually clear it by:
- Pasting chrome://net-internals/#dns into your address bar and click Clear host cache.

- On Firefox, go to about:networking#dns and click Clear DNS Cache.
After flushing, it’s a good idea to restart your browser or computer to ensure all applications use the fresh data.
2. Check if the Site is Down Globally
Sometimes the error can be a ‘you‘ problem instead of an ‘everyone‘ problem. So, before you spend too much time troubleshooting your local connection, check if the website is down. You can use free tools like Is It Down Right Now for this.

If the test comes back saying the site is down globally, you have your answer. The server is offline, and there’s nothing you can do on your end except wait. If the tool says the site is up, then the 504 error is due to your specific connection or device.
3. Temporarily Disable Your VPN or Proxy
If the website is working for everyone else but you’re still seeing a 504 error, your VPN or proxy could be the cause.
VPNs and proxies route traffic through an intermediate server before it reaches the actual site. If the VPN server is experiencing high latency, network issues, or a temporary outage, the request may never reach the destination in time.
As a result, your browser may display a 504 Gateway Timeout error even though the website itself is working normally.
To test this, just toggle your VPN off, clear browser cache, and refresh the page.

If the site loads normally now, you know your VPN was causing the issue. You can usually fix this by simply switching to a different VPN server location before turning it back on.
How Cloudways Helps Prevent 504 Errors
Like I mentioned earlier, the cause of this error is mostly on the server side. So, your hosting plays a major role in avoiding this error in the first place.
While Copilot acts as your automated diagnostic assistant to pinpoint the exact root cause of a 504, Cloudways also provides features that help keep your site running while you address the issue.
Auto-Healing Servers
A lot of 504 errors happen when a core service like Nginx or PHP-FPM freezes up. Instead of waiting for you to realize that your site is down, our servers have an auto-healing feature.
If a process hangs up, the system automatically detects the crash and restarts the service. This gets your site back online immediately, giving you time to check your Copilot Insights to find out exactly why the service crashed in the first place so you can stop it from happening again.
UI-Level Timeout Controls
Remember the PHP and Nginx timeout limits I talked about adjusting earlier?
If you host with us, you don’t need to mess around with .htaccess or php.ini files using FTP. You can instead go to Server Management > Settings & Packages in your dashboard and increase your Execution Limit directly from there.

Dedicated Resources & Quick Scaling
Shared hosting is known for causing 504 errors because there is more than one website on a single server that can eat up all the CPU. With Cloudways, your server resources are dedicated only to your site.
If you get hit by a high traffic spike, you can simply use the 1-click scaling feature to add more RAM and CPU on the fly to handle the load.

Helpful Add-ons
We also offer a few built-in add-ons to stop server timeouts at the source like:
- SafeUpdates, which automatically tests plugin updates on a staging site so a bad update never crashes your live site.
- Cloudflare Enterprise, which caches your site’s content across its global network, allowing cached requests to be served from the edge instead of your origin server. This helps reduce server load during traffic spikes.
- New Relic for manual code profiling. While Copilot automatically interprets your logs to give you plain-English answers on what caused a timeout, our New Relic integration gives developers access to the raw data stream if they want to manually trace application performance themselves.
Wrapping Up!
Whether you’re visiting a website or managing one, a 504 Gateway Timeout error means a request took longer than expected to complete.
For visitors, the problem is mostly out of your hands. Aside from a hard refresh, flushing your DNS, or pausing your VPN, your best bet is to just wait for the webmaster.
For website owners, a 504 error is a clear sign your server is struggling. You can manually check PHP limits and dig through error logs to find the bottleneck, or you can let Cloudways Copilot automate the diagnostics to instantly pinpoint the exact heavy script causing the timeout.
Ultimately, your hosting choice plays a massive role in your site’s reliability. If you are tired of random server timeouts, migrate to Cloudways. We offer top cloud providers such as AWS, Google Cloud, DigitalOcean, Vultr, and Linode, backed by dedicated resources, auto-healing servers, and automated Copilot diagnostics to keep your site running smoothly.
Frequently Asked Questions
Q. Why am I getting a 504 error?
A 504 Gateway Timeout error occurs when your server does not receive a timely response from an upstream server, such as a database or external resource. It can happen due to server overload, slow third-party services, or issues with your internet connection.
Q. How do I fix the 504 error in WordPress?
To fix a 504 error in WordPress:
- Check server status: Ensure your hosting provider is not experiencing downtime.
- Increase PHP limits: Increase PHP execution time or memory limits in the php.ini or .htaccess file.
- Optimize plugins: Disable or update any plugins that may be causing delays.
- Contact hosting provider: Reach out to your hosting provider (like Cloudways) to ensure your server is properly configured.
- Check third-party services: Ensure any external APIs or services are responding correctly.
Q. How do I prevent 504 errors?
To prevent 504 errors:
- Optimize server performance: Use a reliable hosting provider like Cloudways that offers scalable infrastructure to handle traffic spikes.
- Use a CDN: A Content Delivery Network (CDN) can reduce server load by caching static files.
- Manage plugins: Regularly update and manage plugins to avoid resource-heavy ones.
- Increase timeout settings: Adjust your server’s timeout and memory limits to handle larger traffic and data.
Q. Can you monitor the 504 Gateway timeout error?
Yes, monitoring tools like Cloudways’ integrated performance monitoring and third-party services such as UptimeRobot can alert you when a 504 Gateway Timeout error occurs. These tools help track server response times and provide insights into potential issues before they affect users.
Q. Is a CDN causing my 504 errors?
A CDN could potentially cause a 504 error if there is a connectivity issue between the CDN and your origin server. It might also happen if the CDN is caching outdated or incorrect content. To fix this, clear your CDN cache or temporarily disable it to see if the error resolves.
Q. Is the 504 error always a hosting issue?
No, a 504 error is not always a hosting issue. While server misconfiguration or downtime from your hosting provider (such as Cloudways) can cause the error, it can also be triggered by slow third-party services, DNS problems, or issues with external APIs.
Abdul Rehman
Abdul is a tech-savvy, coffee-fueled, and creatively driven marketer who loves keeping up with the latest software updates and tech gadgets. He's also a skilled technical writer who can explain complex concepts simply for a broad audience. Abdul enjoys sharing his knowledge of the Cloud industry through user manuals, documentation, and blog posts.