Skip to content

Troubleshooting guide

Cloudflare error 524: a timeout occurred

A 524 means your server accepted the connection and then took too long to answer. On most Cloudflare plans the limit is 100 seconds, and the request behind it is almost always one specific slow operation.

5 min read10 sectionsUpdated

On this page

Key points

  • 524 = connected, but no HTTP response within 100 seconds (the default proxy read timeout).
  • It is a slow request, not a down server: a long query, export, report, import or upstream call.
  • Raising timeouts rarely fixes it. Move long work to a background job and return early.
  • Traces show exactly which span used the 100 seconds.

What error 524 means

The TCP connection worked and the request reached your server, but the first byte of the response did not arrive in time. Cloudflare closes the request and shows 524; your application may keep working on it and finish later, so the work can still complete even though the visitor saw an error.

ErrorWhat Cloudflare sawWhere to look first
520A connection, then an empty, invalid or reset responseOrigin application and web server error logs
521The origin actively refused the TCP connectionIs the web server running; does the firewall allow Cloudflare
522No TCP connection within Cloudflare's time limitServer load, firewall dropping packets, wrong DNS record
524A connection, but no HTTP response within 100 secondsSlow requests: long queries, reports, exports, uploads

The usual causes

  • A slow database query: a missing index, a table scan on a large table, lock waits. See finding slow database queries.
  • Long synchronous work in the request: generating a big report or export, image or video processing, bulk imports, sending many emails.
  • A slow upstream API that your code waits on without its own timeout.
  • Exhausted worker pools: requests queue behind others until they run out of time.
  • Large uploads processed inline after the upload finishes.

Confirm it

Find which URL is slow. Your access log shows the request with a long duration, or a trace shows the span that used the time.

bash
# time the request directly against the origin
curl -s -o /dev/null -w 'ttfb=%{time_starttransfer}s total=%{time_total}s\n' \
  --resolve example.com:443:203.0.113.10 https://example.com/reports/export
# nginx: log request time to spot the slow URLs ($request_time in log_format)
sudo awk '$NF > 60' /var/log/nginx/access.log | tail

Fix it

  1. Make the slow operation fast where you can: add the missing index, cache the result, page the data.
  2. Move long work off the request. Accept the job, return 202 Accepted with a job ID, process it in a queue worker, and let the page poll or receive a notification. See monitoring background jobs and queues for keeping those workers healthy.
  3. Put timeouts on upstream calls shorter than the proxy's limit, and fail with a clear error instead of hanging.
  4. Stream long responses where the format allows it, so bytes start flowing early.
  5. Raise the limit only as a last resort. Higher proxy timeouts are an Enterprise feature on Cloudflare and only hide the slow request.

Catch it before your visitors do

Cloudflare's error pages hide the cause, so measure both sides:

  1. Check the public URL through Cloudflare with an uptime monitor from several regions. That is what visitors get, 52x errors included.
  2. Check the origin directly with a second monitor on the origin's address or a health endpoint that bypasses Cloudflare. If only the first one fails, the problem is between Cloudflare and your server; if both fail, it is the server.
  3. Alert on the status code, not only on "down". A rule for any 52x response on the public check tells you which of the four errors it is before anyone opens a log.
  4. Keep the CF-Ray ID. It is in the error page and in the cf-ray response header; Cloudflare support and your own logs can be matched with it.

With APM on the origin you can also see the request that took 100 seconds behind a 524, instead of guessing.

Frequently asked questions

How long is Cloudflare's timeout?

On most plans Cloudflare waits 100 seconds for the first byte of the response after connecting. Enterprise plans can change the proxy read timeout.

Did the request still run after a 524?

Often yes. Cloudflare stopped waiting, but your server may finish the work. That is why retrying a 524 can create duplicate orders or exports unless the endpoint is idempotent.

How do I find the slow request?

Use request durations in your access log or traces from an APM tool. A trace shows which database call, upstream request or function used the time.

Check it now, free

Watch your own site and services with VitalRix

Uptime checks, APM, logs, real-user monitoring, alerts and status pages in one place. Every product has a free tier and no credit card is needed.