Plugins Plugin hub Backup SEO Caching Security Forms WooCommerce Images Best backup plugins
Hosting Hosting directory Shared Managed Cloud India
Themes & builders Compare Rank Math vs Yoast
Tools All tools Hosting finder Plugin stack builder Cost calculator Salt generator Theme detector Who is hosting this? Speed test Headline analyzer robots.txt generator Redirect generator Uptime calculator Blog name generator
Best lists Best backup plugins Deals
Guides All guides Speed up WordPress Choose hosting Back up WordPress
How we test

Troubleshooting · Troubleshooting

How to Fix the 504 Gateway Timeout Error in WordPress

Short answer

A 504 Gateway Timeout means a gateway or proxy waited too long for WordPress to answer, so it stopped waiting and showed the error. Find the page or task that is slow, then fix that cause first. Raise a timeout only when the task truly needs more time, and ask your host when the limit is set by the server.

Key takeaways

  • A 504 means the gateway got no answer in time, while a 502 means it got a bad answer.
  • Nginx waits 60 seconds by default between reads from the upstream server, as of November 2026.
  • PHP stops a web script after 30 seconds by default, unless your host sets a higher limit.
  • Cloudflare shows its own 524 code when the origin sends no answer within 125 seconds.
  • Fix the slow plugin, query, or task first, because a higher timeout only hides a slow site.

What does a 504 Gateway Timeout error mean in WordPress?

A 504 Gateway Timeout means a gateway or proxy waited for WordPress and got no answer before its timer ran out.

A gateway is a server that sits between a visitor and your site. It can be Nginx, a load balancer, or a CDN such as Cloudflare. It forwards the request to the server that runs WordPress, then waits for a page in return.

MDN defines the 504 status as a server error where the gateway, while acting as a gateway or proxy, did not get a response in time from the upstream server. The upstream server is the one that runs WordPress, PHP, and the database.

The error does not mean your browser is broken. It means the reply took too long at some point between the gateway and WordPress. A single slow page, a long import, or a stuck task can trigger it while the rest of the site still loads.

How is a 504 different from a 502, 503, and 524?

A 504 means no answer arrived in time, a 502 means a bad answer arrived, and a 503 means the service said it was not available.

The codes look alike, but each one points at a different failure. Use the table to tell them apart before you change any setting.

CodeWhat happenedWhat it tells you
502 Bad GatewayThe gateway got an invalid responseThe upstream answered, but the answer was broken
503 Service UnavailableThe server said it was not readyThe service was down, busy, or in maintenance
504 Gateway TimeoutThe gateway got no response in timeThe upstream was too slow or silent
524 (Cloudflare only)Cloudflare got no response in timeThe origin was too slow for Cloudflare

MDN draws the same line: a 504 is similar to a 502, except that in a 504 the proxy did not receive any HTTP response from the origin within a certain time.

Cloudflare uses 524 for its own timeout. Cloudflare says error 524 means Cloudflare connected to the origin, but the origin gave no HTTP response before the default 125 seconds Proxy Read Timeout, as of November 2026.

What causes a 504 Gateway Timeout on a WordPress site?

A 504 is most often caused by a slow or stuck task on the server, not by a broken link or a wrong URL.

Common causes include a slow database query, a plugin that calls a slow outside service, a large import or export, and a server that has run out of free PHP workers or memory. A task that needs more time than the gateway allows will fail the same way each time it runs.

Cloudflare lists the common origin causes as excessive server loads, crashes, network failures, and applications or services that timed out or were blocked. It also says the most common source of a Cloudflare-branded 502 or 504 is the origin server itself.

DNS can also play a part after a move or a DNS change. If the domain points at the wrong server, the gateway may wait for a server that never answers that hostname. Check the A record and the proxy setting before you blame WordPress.

A visitor-side cause is less common. MDN notes that client networking errors are an exception, mainly when the site works for other visitors and the affected visitor uses a VPN or a custom network setup.

How do you find which page or task triggers the 504?

Note the exact URL, the exact time, and what you clicked, then check whether the error hits one page, one task, or the whole site.

Start with the pattern. A 504 on one admin page points at that page.

A 504 only during an import, a backup, or a bulk edit points at that task. A 504 on every page points at the server or the gateway.

Use these checks in order:

  • Load the home page, then the failing page, in a new private window.
  • Try the same page from another network or device.
  • Note how many seconds pass before the error appears.
  • Check whether the task still runs in the background after the error.

A fixed delay is a strong clue. If the page always fails at about 60 seconds, a 60-second limit fired. If it always fails at about 125 seconds behind Cloudflare, the Cloudflare limit fired.

Turn on logging on a staging copy first. WordPress says to add WP_DEBUG, WP_DEBUG_LOG, and WP_DEBUG_DISPLAY lines to wp-config.php before the line that reads “That's all, stop editing!” Then read wp-content/debug.log for the error that happened at the same time.

How do you fix a 504 caused by a slow plugin or theme?

Disable the most recent plugin or theme change first, then test the failing page after each change.

A plugin that runs a slow query or waits on an outside API can hold a request until the gateway gives up. The fix is to find that plugin, not to raise every timeout on the server.

Follow these steps:

  1. Back up the site before you change anything. See how to back up WordPress for the steps to take first.
  2. Go to Plugins → Installed Plugins in the WordPress admin.
  3. Deactivate the plugin you changed most recently, then load the failing page.
  4. If the page loads, leave that plugin off and contact its author or find a lighter option.
  5. If the page still fails, reactivate it and test the next recent plugin.
  6. Switch to a default theme such as Twenty Twenty-Five to test a theme cause.

Use the Health Check plugin's troubleshooting mode when you cannot take the live site down. It lets you test with plugins off for your session only, while visitors still see the normal site.

Check for tasks that run on every page load. A slow widget, a feed, or a check for updates can add seconds to each request. Remove or cache that item, then test again.

How do you fix a 504 caused by PHP and server timeouts?

Raise the PHP and server timeouts together, in small steps, and only for a task that truly needs more time.

Each layer has its own timer. Raising one timer does nothing when a shorter timer in another layer fires first. The table shows the defaults you need to know, as of November 2026.

LayerSettingDefault
PHPmax_execution_time30 seconds
Nginx proxyproxy_read_timeout60 seconds
Nginx FastCGIfastcgi_read_timeout60 seconds
ApacheTimeout300 seconds
CloudflareProxy Read Timeout125 seconds

PHP lists max_execution_time with a default of 30 seconds for web requests and 0 for the command line. It also notes that Apache has a Timeout directive and IIS has a CGI timeout, and both default to 300 seconds.

Nginx lists proxy_read_timeout with a default of 60 seconds. It also says the timeout runs only between two successive read operations, not for the whole response, so a reply that sends data in small parts can still pass.

On a managed host, ask support to raise max_execution_time and the matching server timeout. On a server you manage, edit php.ini for PHP, then edit the Nginx site file for fastcgi_read_timeout in the PHP location block. Test the change with nginx -t, then reload Nginx.

Check the memory limit too. WordPress says WordPress tries to raise PHP memory to 40MB for a single site and 64MB for multisite. Add define( 'WP_MEMORY_LIMIT', '256M' ); to wp-config.php only when your host allows a higher PHP memory limit.

How do you fix a 504 when Cloudflare is in front of WordPress?

First tell whether the 504 came from your origin or from Cloudflare, then fix the side that sent it.

A Cloudflare-branded 504 page usually means your origin sent the 504. A blank 504 page with no Cloudflare branding usually means the error came from Cloudflare itself. Cloudflare gives that test in its 502 and 504 guide.

To test the origin, pause Cloudflare for a short time. In the Cloudflare dashboard, go to Overview → Advanced Actions → Pause Cloudflare on Site. Cloudflare says pausing takes 5 minutes or less and sends traffic straight to your origin.

If the page loads with Cloudflare paused, the fault is in the path through Cloudflare or at the origin. If it still fails, the fault is at the origin, so work through the PHP and plugin steps above.

Do not raise your own server timeout past 125 seconds to fix a Cloudflare 524. Cloudflare says Enterprise customers can raise the 524 timeout up to 6,000 seconds, while other plans cannot. For long exports, move the task behind a subdomain set to DNS only in the Cloudflare DNS app.

For help with the setup itself, see how to set up Cloudflare for WordPress. It covers the settings that affect how Cloudflare talks to your origin.

How do you check that the 504 fix worked?

Load the exact failing page 3 times, run the exact failing task once, and watch the server log for the same time window.

A single fast load is not proof. A slow task can pass once by luck and fail again under load. Repeat the test, then check the numbers.

Use this checklist:

  • The failing page loads in under a few seconds on 3 tries.
  • The import, export, or save that failed now finishes.
  • The error log shows no new 504 or timeout entry for that URL.
  • The site loads at a normal speed. See how to reduce server response time in WordPress if pages are still slow.
  • The fix holds after you reactivate each plugin you turned off.

If the page loads but takes close to the timeout limit, the cause is still there. A page that takes 55 seconds on a 60-second limit will fail again when traffic rises. Fix the slow query or task before you call the job done.

When should you contact your host about a 504?

Contact your host when the 504 hits the whole site, when you cannot change PHP or server settings, or when the logs point at the server.

Cloudflare says to contact your hosting provider for 502 and 504 errors from the origin. It also says the cause is not always in the origin error logs, so check the logs of any load balancer, cache, proxy, or firewall between Cloudflare and the origin.

Send your host the exact error code, the exact URL, and the time with its timezone. Add the Ray ID from the bottom of a Cloudflare error page when you have one. That detail lets support find your request in their logs.

Ask these questions:

  • What is the current max_execution_time and PHP memory limit on my plan?
  • How many PHP workers does my plan allow?
  • Did the server hit a CPU, memory, or worker limit at the time of the error?
  • Can you raise the timeout for the slow task, or should the task run in smaller parts?

If your host says the plan is too small for the task, split the task or move it to a larger plan. See how to tell if your host is slowing WordPress down before you choose.

Check how many PHP workers you need before you pick a larger plan.

What mistakes should you avoid?

Do not raise timeouts to very high values, do not edit live files without a backup, and do not treat a 504 as a 502 or a 503.

Raising a timeout from 60 seconds to 600 seconds lets a slow request hold a PHP worker for 10 minutes. That can block other visitors and turn one slow page into a site-wide outage. Raise limits in small steps, and only for a task that truly needs more time.

Avoid these errors:

  • Raising only the Nginx timeout while PHP still stops at 30 seconds.
  • Raising only the PHP timeout while Nginx still stops at 60 seconds.
  • Editing wp-config.php after the “stop editing” line, where the change is ignored.
  • Testing a fix on the live site with no backup and no staging copy.
  • Clearing the cache and hoping the error goes away, when the slow task is still there.

Frequently asked questions

Does a 504 Gateway Timeout mean my WordPress site is down?

Not always. A 504 means one request timed out, often on a single slow page or task. If the home page loads and only one page fails, the site is up and that page or task is slow. If every page fails with a 504, the server or gateway is the likely cause, so check the host and the error log next.

How long should I wait before I reload a page that shows a 504?

Wait 1 or 2 minutes, then reload once. A short spike in traffic or a stuck task can clear on its own. If the same page fails again at about the same delay, do not keep reloading. Note the URL and the time, then work through the cause, because repeated reloads can add more load to a busy server.

Can a plugin cause a 504 Gateway Timeout?

Yes. A plugin can cause a 504 when it runs a slow database query, waits on a slow outside service, or starts a long task inside a normal page request. Deactivate the most recent plugin first and test the failing page. If the page loads, that plugin is the likely cause, so leave it off until you find a fix or a lighter option.

Why does my site show a 504 only when I save, import, or export?

Those tasks take longer than a normal page load, so they are the first to hit a timeout. A large import, a backup, or a bulk edit can run past the PHP limit of 30 seconds or the Nginx limit of 60 seconds. Split the task into smaller parts, run it in the background when the tool allows it, or ask your host to raise the matching limit.

Is a Cloudflare 524 the same as a WordPress 504?

No. A 524 is Cloudflare's own code for a timeout between Cloudflare and your origin, with a default limit of 125 seconds. A 504 is the standard HTTP code for a gateway timeout, and it can come from your origin or from another gateway. Fix the slow origin task first, because raising your own server timeout past 125 seconds will not change the Cloudflare limit.

Sources

  1. 504 Gateway Timeout MDN Web Docs
  2. Error 502 or 504 Cloudflare Support docs
  3. Error 524: a timeout occurred Cloudflare Support docs
  4. Module ngx_http_proxy_module Nginx
  5. PHP: Runtime Configuration PHP
  6. Debugging in WordPress WordPress Developer Resources
  7. Editing wp-config.php WordPress Developer Resources
  8. Pause Cloudflare Cloudflare Fundamentals docs

Is your product missing, or something out of date?

Tell us what to add or correct. We read every note and reply when we need a source. A message does not buy a ranking.

About the editors

WPLegible editors

Researched from the primary sources listed above and checked against our editorial rules. About the site · How we test