sfw/fix
Error 524 high

Cloudflare Error 524: A Timeout Occurred

Cloudflare connected to your origin fine but the origin took too long to send back an HTTP response.

What you see

Error 524
A timeout occurred
What happened? The origin web server timed out responding to this request.

What’s actually happening

One slow endpoint hangs for roughly a minute and a half, then flips to the 524 page, while the rest of the site stays up. It's almost always a specific URL — a report export, a checkout callback, an admin bulk action — not the whole domain. The TCP connection succeeds, so this is purely about response time, not reachability.

Common causes

  • A long-running request that exceeds Cloudflare's default ~100-second Proxy Read Timeout (heavy SQL query, large export, slow third-party API call inside the request).
  • The app worker handling the request is blocked or deadlocked and never writes a response.
  • Origin is overloaded enough that requests queue behind others for longer than the timeout.
  • A backend service the request depends on (database, payment gateway, search cluster) is itself slow or hung.
  • Genuinely synchronous heavy work (PDF generation, video transcode, large import) being done inside an HTTP request instead of a background job.

How to fix it

  1. Find the slow endpoint and time it directly against the originHit the origin IP, bypassing Cloudflare: `curl -w 'total: %{time_total}s\n' -o /dev/null -s --connect-to example.com:443:ORIGIN_IP:443 https://example.com/the-slow-path`. If that crosses ~100s, you've reproduced it and the fix belongs at the origin, not in Cloudflare.
  2. Move the heavy work out of the request cyclePush exports, report builds, and bulk operations to a background queue (Sidekiq, Celery, a worker) and return a job ID immediately. Poll for completion from the client. This is the real fix — anything that legitimately takes minutes should never block an HTTP response sitting behind a CDN.
  3. Profile and fix the underlying slownessTurn on the slow query log (MySQL `slow_query_log`, Postgres `log_min_duration_statement`) and check for a missing index or an N+1. A single unindexed query on a grown table is the classic 524 once the row count crosses some threshold.
  4. For genuinely long endpoints, take them off the proxyPut the specific long-running hostname (e.g. `exports.example.com`) on a DNS-only / grey-clouded record so requests skip Cloudflare's proxy and its read timeout. You lose Cloudflare's protection on that subdomain, so scope it tightly.
  5. Enterprise: raise the Proxy Read TimeoutOn Enterprise plans you can increase the timeout (up to 6000s) via a Configuration/Cache Rule's Proxy Read Timeout setting or the Edit Zone Settings API. Treat this as a stopgap — a request that needs minutes is an architecture smell, not a timeout-config problem.

Stop it recurring

Keep request handlers under a few seconds by offloading anything heavy to background jobs, and alert on p99 latency per route so a slow endpoint surfaces before it hits the timeout wall.

Related errors