Cloudflare error 524: a timeout occurred
Your server took longer than Cloudflare's 100-second limit to respond. Find the slow part and move long tasks to background jobs.
· 3 min read · By the Spot Downtime team
Error 524: A timeout occurred means Cloudflare connected to your server just fine, sent the request, and then waited too long for an answer. By default, Cloudflare waits 100 seconds for a proxied request. If your server hasn't started responding by then, the visitor gets a 524.
Your server is up. Something in it is slow, or the request is doing too much work for a single HTTP request.
Common causes
Long-running work in a request
Exports, report generation, image processing, bulk imports, or an admin action that loops over every record. These are fine with a hundred rows and time out with a hundred thousand.
A slow database query
A query on a table that grew, missing an index, or waiting on a lock held by another transaction. Check the database's slow query log around the time of the 524s.
A call to another service that hangs
Your code calls a payment provider or an internal API without a timeout. When that service is slow, your request waits as long as it does. Always set timeouts on outbound calls, well under 100 seconds.
Overloaded workers
All PHP-FPM or app workers are busy, so new requests queue. Each one is quick, but the wait in the queue pushes it past the limit.
How to fix it
- Move long tasks to a background job. Accept the request, queue the work, return
202 Acceptedand let the user poll or get notified when it's done. - Find the slow part. Your app's logs or APM show which endpoint and which query took the time.
- Bypass the proxy for genuinely long admin tasks, using a DNS-only (grey cloud) subdomain, if you can't move them to a background job yet.
# time a request directly at the origin, bypassing Cloudflare
curl -o /dev/null -s -w "ttfb: %{time_starttransfer}s\n" \
--resolve example.com:443:203.0.113.10 https://example.com/slow-pageSlow comes before down
Without Cloudflare, the same problem appears as a 504 Gateway Timeout from your own proxy.
Keep reading
- Cloudflare errors · TroubleshootingCloudflare error 520: web server is returning an unknown errorCloudflare's catch-all error means your origin sent something empty or invalid. The usual causes and how to test your origin directly, bypassing Cloudflare.October 5, 2026 · 3 min read
- Cloudflare errors · TroubleshootingCloudflare error 521: web server is downYour origin refused Cloudflare's connection. How to tell whether the web server is stopped or a firewall is blocking Cloudflare, and how to fix both.October 5, 2026 · 3 min read