Skip to content
5xx · server errorSent by CDNNon-standard · Cloudflare

524A Timeout Occurred

Cloudflare connected to your server, then waited too long for it to answer.

How you get a 524

Cloudflare forwards the request and starts its 125 second timer. The database is stuck on a long query and no answer comes back in time. The CDN gives up and sends 524.

Who sends itCDN

  1. Browser
  2. CDN
  3. Proxy
  4. App
  5. DB

Only Cloudflare sends it. It is Cloudflare's own code for an origin that accepted the connection but did not reply in time. A standard proxy in the same position would answer 504.

In short

What a 524 A Timeout Occurred means

A 524 is Cloudflare's own code and not part of the HTTP standard. It means Cloudflare connected to your origin server successfully, sent the request, and then waited for an answer that did not arrive within its limit, 125 seconds by default. Cloudflare writes the error itself. It is the edge's version of 504 Gateway Timeout, with the same important catch: the origin has usually not failed. It is still working on a long query, export or report, and may finish after the visitor has been shown the error. If a proxy on your own side had given up first, you would see a standard 504 passed through instead. Raising the limit is rarely the fix. Long jobs belong in the background, with the page checking back for the result.

Common causes of a 524

  1. 1A long-running request: a report, export or import that takes more than the limit.

    How to check: Time the same request directly against the origin.

    curl -s -o /dev/null -w '%{time_total}\n' --resolve example.com:443:<origin-ip> https://example.com/report
  2. 2A slow or locked database query holds the request.

    How to check: Look for long-running statements in the database at the time of the error.

  3. 3The origin is overloaded and requests queue for a free worker.

    How to check: Check worker and connection pool saturation on the origin, and its load at that time.

  4. 4The origin's own proxy has a longer timeout than Cloudflare, so Cloudflare always gives up first.

    How to check: Compare your proxy's read timeout with Cloudflare's limit. The shorter one decides which error you see.

Retry or not?

Safe to retry with backoff · Idempotent requests only

As with 504, the origin may still complete the work after the error is shown. Repeat reads with backoff. Repeat writes only if they carry an idempotency key.

Headers that matter

cf-ray
Cloudflare's ID for this request. Use it to find the entry in Cloudflare's logs and the matching time at your origin.
Server: cloudflare
Confirms Cloudflare's timer fired. A 504 with your own proxy's page means your proxy gave up first.

In the real world

RFC vs real deployments

No RFC defines 524. It sits in Cloudflare's private 520 to 527 range, next to 522, which means Cloudflare could not connect to the origin at all, and 523, which means it could not find a route to it. Cloudflare lets Enterprise customers raise the timeout. The standard's own code for this situation is 504, and Cloudflare passes a 504 through unchanged when your origin sends one.

Seen in a real outage

Requests that hang are usually waiting behind something. At Handshake in 2017, adding a foreign key from an empty table froze the whole site for a minute: every query queued behind one lock.

Your turn

Which code is it?

A report page behind Cloudflare fails with error 524 after exactly 125 seconds. The origin's log shows the report finishing with status 200 after 160 seconds. What is the right fix?

524 questions

Is 524 a standard HTTP status code?
No. It is specific to Cloudflare. It means Cloudflare connected to the origin server but did not get a response within its timeout.
What is the difference between 524 and 504?
Both are timeouts. A 504 is the standard code and is sent by whichever proxy gave up. A 524 is Cloudflare's own code for when its edge is the one that gave up.
What is the difference between 522 and 524?
With 522, Cloudflare could not establish a connection to the origin at all. With 524 it connected, and then the origin took too long to reply.

Sources: Cloudflare: Error 524 ↗ · Cloudflare: Error 522 ↗ · Report a problem

Diagrams are our own simulations. All wording is original and paraphrases the linked sources.

Practise this in the DNS / HTTP track

Two-minute animated lessons, then boss fights from real outages. Free, no account needed.

Start the track