Skip to content

Cloudflare error 524: a timeout occurred — fixing long requests behind the 100-second limit

Cloudflare error 524 means the origin accepted the request but did not answer within 100 seconds. Slow PHP, heavy exports, and long database queries are the usual causes — here is how to fix them without an Enterprise plan.

Cloudflare error 524 means the connection to your origin worked, the HTTP request was delivered, and then the origin sat on it too long: no HTTP response came back within 100 seconds, so the edge gave up. This is not a broken server — it is a slow endpoint. The fix is either making that request finish faster (usually a slow database query or a heavy PHP task) or moving work that legitimately needs minutes off the proxied request path, because on Free, Pro, and Business plans the 100-second ceiling is not adjustable.

What’s happening

The path is browser → Cloudflare edge → origin. With a 524, every network step succeeded — TCP connected, TLS negotiated, request sent. The edge then starts a countdown, and if the origin has not returned HTTP response headers within roughly 100 seconds, Cloudflare abandons the wait and serves the 524 page, documented in the HTTP status code reference. Meanwhile your origin is often still working on the request — the PHP process keeps running, the export keeps exporting, and it eventually finishes for nobody.

The plan detail matters here more than for any other 52x error: the proxy read timeout is fixed at 100 seconds on Free, Pro, and Business. Raising it is Enterprise-only. So every “increase the timeout” answer you find in forums is a dead end unless you are on Enterprise; for everyone else, the engineering options are: make it faster, make it asynchronous, or take that route off the proxy.

Typical producers of 100-second requests: report generation and CSV/product exports, WordPress admin actions (imports, bulk edits, plugin-driven migrations), a database query missing an index that degrades as the table grows, an external API call inside the request with no timeout of its own, and web-triggered cron or backup jobs.

What to check first

  • Which URL exactly times out? A 524 is per-endpoint. One slow admin action and a site-wide problem are different investigations.
  • How long does the endpoint really take? Time it directly against the origin. 105 seconds needs a small optimization; 20 minutes needs an architecture change.
  • Did it get slower gradually? Growing tables and missing indexes degrade over months and cross the 100-second line one day without anything “changing”.
  • Is a lower timeout firing first? If the failure arrives at 30 or 60 seconds, the cut is your own stack (PHP, proxy) and the 524 you occasionally see is a different, longer path.
  • Is the database healthy right now? A lock pile-up makes normally fast pages cross 100 seconds in bursts.

How to verify

Time the failing endpoint straight against the origin (IP from DNS → Records), with a generous client timeout so you measure the origin rather than your own patience:

# How long does the endpoint actually take, bypassing Cloudflare?
curl -sv -o /dev/null -w 'code=%{http_code} total=%{time_total}s ttfb=%{time_starttransfer}s\n' \
  --max-time 600 --resolve example.com:443:203.0.113.10 https://example.com/wp-admin/admin-ajax.php

# What is the database doing while it runs?
mysql -e "SHOW FULL PROCESSLIST;"

# Slow query log - the usual home of the real culprit
tail -50 /var/log/mysql/mysql-slow.log

# PHP-FPM: requests running long, or killed by its own limits
grep -E "executing too slow|terminated" /var/log/php*-fpm.log | tail -20

If time_total lands past 100 seconds with a 200 response, you have reproduced the 524’s cause exactly: the origin finishes, just too late for the edge.

The fix

  1. Find and fix the slow query — the most common real cause. SHOW FULL PROCESSLIST during a run and the slow query log will name it; the fix is usually an index, a rewritten JOIN, or pagination instead of a full-table pull. This turns a 90-160 second endpoint into a 2-second one and the 524 disappears without touching anything else.
  2. Move long work off the request — exports, imports, report builds, and bulk operations belong in a background job: a queue worker, a real cron, or WP-CLI for WordPress (wp export on the server instead of the admin-screen exporter). The HTTP request then just enqueues and polls, returning in milliseconds.
  3. Align origin timeouts below 100 seconds — set PHP max_execution_time, PHP-FPM request_terminate_timeout, and the web server’s proxy/FastCGI read timeouts (fastcgi_read_timeout, ProxyTimeout) to something below 100 so the origin fails fast with its own error page and logs instead of letting the edge cut the line blind. Raising these limits above 100 accomplishes nothing behind Cloudflare — the visitor gets the 524 regardless.
  4. Take the long endpoint off the proxy — for a legitimately long admin route, serve it from a hostname that is DNS-only (grey cloud), where no Cloudflare timeout applies. Understand the trade first: that hostname loses the WAF and hides nothing — see DNS-only vs proxied for exactly what you give up.
  5. Enterprise-only: raise the proxy timeout — on an Enterprise plan the read timeout can be extended (up to 6,000 seconds). Worth knowing so you can recognize the option, and worth ignoring as a fix if you are not on Enterprise.

When this fix is wrong

If the timeout consistently hits at a round number well under 100 seconds — 30, 60, 90 — Cloudflare did not cut the request; your own PHP, FastCGI, or upstream proxy did, and the browser may show an origin 500/504 rather than a true 524. And if 524s appear in bursts across many normally-fast URLs, do not optimize endpoints one by one: look for a shared bottleneck, usually database locks or a saturated PHP-FPM pool.

Common mistakes

  • Raising max_execution_time to 300 and expecting the 524 to stop — the edge still cuts at 100 seconds; you have only ensured the origin wastes more work after the visitor is gone.
  • Retrying the slow request repeatedly, stacking multiple copies of a heavy job on the origin and making everything slower — each retry runs to completion server-side even though every response is discarded.
  • Blaming Cloudflare for a query that got slower every month of the past year.
  • Grey-clouding the whole site to fix one slow admin endpoint, giving up edge protection everywhere for a problem one route has.

Prevention

  • Track endpoint response times and alert at 30 seconds — long before the 100-second cliff.
  • Review the slow query log monthly; indexes rot as data grows.
  • Keep exports, imports, and reports on queue workers or cron from day one, not as an incident response.
  • Set explicit timeouts on outbound API calls inside requests, so a slow third party fails your request in 5 seconds instead of 100. On WordPress, the perf side of this is covered in why WordPress is still slow behind Cloudflare.
  • Document which hostnames are proxied and which are DNS-only, so nobody “fixes” a 524 by silently exposing an origin.

A 524 is the most honest of the Cloudflare errors: the request really was too slow, and the edge is just the first thing that said so out loud. If the error keeps coming back, the problem usually sits between Cloudflare and the origin — Stack Harbor operates that whole path under Managed Cloud Ops, and you can book an infrastructure review.