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.
| Error | What Cloudflare saw | Where to look first |
|---|---|---|
| 520 | A connection, then an empty, invalid or reset response | Origin application and web server error logs |
| 521 | The origin actively refused the TCP connection | Is the web server running; does the firewall allow Cloudflare |
| 522 | No TCP connection within Cloudflare's time limit | Server load, firewall dropping packets, wrong DNS record |
| 524 | A connection, but no HTTP response within 100 seconds | Slow 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.
# 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 | tailFix it
- Make the slow operation fast where you can: add the missing index, cache the result, page the data.
- Move long work off the request. Accept the job, return
202 Acceptedwith 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. - Put timeouts on upstream calls shorter than the proxy's limit, and fail with a clear error instead of hanging.
- Stream long responses where the format allows it, so bytes start flowing early.
- 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:
- Check the public URL through Cloudflare with an uptime monitor from several regions. That is what visitors get, 52x errors included.
- 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.
- 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.
- 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.
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
- Is Cloudflare down? Live status: checked every few minutes, with outage history.
- Website down checker: Is it down for everyone or just me? Check any site now.
Related reading
- Cloudflare error 523: origin is unreachable: Fix Cloudflare error 523 Origin is Unreachable: wrong DNS IPs, routing problems at the host and firewalls, with tests that confirm where traffic stops.
- Cloudflare error 1016 "Origin DNS error": how to fix it: Fix Cloudflare error 1016 Origin DNS error: CNAME records pointing to names that do not resolve, deleted origins and load balancer pools, with checks.
- Cloudflare error 1020: Access denied: Fix Cloudflare error 1020 Access denied: find the firewall rule that blocked a visitor using the Ray ID, tune WAF rules and allow your monitors and APIs.
- Cloudflare error 525: SSL handshake failed: Fix Cloudflare error 525 SSL handshake failed: origin with no certificate, disabled SNI, cipher mismatches and Full mode, with openssl tests against the origin.
- Cloudflare error 530: how to fix it: Fix Cloudflare error 530, usually shown with error 1033 (Argo Tunnel error) or 1016: stopped cloudflared tunnels, deleted tunnels and origin DNS problems.
- 408 Request Timeout: causes and how to fix it: Understand 408 Request Timeout: slow client uploads, idle keep-alive connections and proxy settings, and how it differs from a 504 Gateway Timeout.
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.