< HTTP/1.1 524 A Timeout Occurred524 A Timeout Occurred
Cloudflare-specific error when the origin server takes too long to respond. Learn how to diagnose and fix 524 timeout errors.
- Cacheable
- No
- Retry?
- Idempotent requests only; the origin may still be working
- Usually sent by
- Cloudflare edge
On this page
TL;DR: HTTP 524 means Cloudflare connected to your server but timed out waiting for it. Check origin request timings, move long jobs to a queue with polling, or raise the read timeout on Enterprise; the default is 125 seconds. A stalled upload to the origin can also hit the separate 30-second write timeout.
What it means
524 is a Cloudflare extension, not a named status in RFC 9110. Clients handle an unfamiliar 5xx as a server error under RFC 9110 status extensibility.
For a read timeout, Cloudflare established the origin connection but did not receive a timely HTTP response. Cloudflare closes the connection and returns 524 to the visitor. The page says “A timeout occurred”. Enterprise customers can raise the proxy read timeout up to 6,000 seconds through the zone settings API, or a Cache Rule for cacheable requests; on other plans it is fixed. A separate 30-second proxy write timeout, which cannot be changed, also produces 524 when writing to the origin stalls. Cloudflare Images uses a 6.5-second write timeout. Cloudflare 524 documentation.
Use Cloudflare’s read/write limits to identify the stalled phase. A handler that waits for a large query before responding can reach the read limit. Treat streaming as a separate endpoint to test through the full proxy chain; merely sending headers early is an incomplete fix. Connection limits.
What you see in your client
Client messages and the command outcomes below are illustrative. For 524, reason text varies with the response and protocol; use the numeric status for diagnosis.
- Axios:
AxiosError: Request failed with status code 524. Its default status check rejects 524; inspecterror.response.statusand headers. Axios source. - fetch: resolves with
response.status === 524andresponse.ok === false. Checkokbefore decoding the body as JSON. Fetch behaviour. - Python requests:
raise_for_status()buildsrequests.exceptions.HTTPError: 524 Server Error: <Reason> for url: https://example.com/api.<Reason>isresponse.reason, not fixed Cloudflare text. Requests source. - curl -f:
curl: (22) The requested URL returned error: 524. Capture headers and body withcurl -sS -D - https://example.com/apiwhile investigating. curl source. - .NET: with no reason phrase,
EnsureSuccessStatusCode()throwsSystem.Net.Http.HttpRequestException: Response status code does not indicate success: 524.With a phrase, it uses524 (<Reason>).in the message. Runtime source, message resource. - Spring WebClient: the generic
WebClientResponseExceptioncarries 524; there is no dedicated 524 subclass. Its message template is524 <Reason> from GET https://example.com/api. SavegetStatusCode().value(), headers andgetResponseBodyAsString(). Spring source.
If an API wrapper logs status_code=524 with no body, preserve the URL, timestamp, elapsed time and CF-Ray. Inspect the HTTP status before attempting JSON parsing; an HTML error page or empty body gives the parser nothing useful to decode. For a state-changing request, check the job or resource state before retrying because the origin may still be working.
Who sent it?
Inspect the status together with server: cloudflare and cf-ray. A read-timeout 524 is near the configured read limit; a write-timeout 524 can arrive much earlier. Distinguish it from 522 (connection/acknowledgement timeout) and 504 (gateway timeout). An origin nginx read timeout or ALB idle timeout can fire first; both default to 60 seconds.
Common causes by stack
- Cloudflare proxy: the 125-second read or 30-second write limit produces 524. Establish which phase stalled before requesting an Enterprise read-timeout increase; the write limit is fixed.
- nginx in front of an app: log
$request_time,$upstream_response_timeand the forwarded$http_cf_ray. A high upstream time sends you to the app; inspect nginx buffering when testing streaming. nginx log variables, upstream timings. - Express, FastAPI, Django, Laravel or Rails behind Cloudflare: a long-running report handler can leave Cloudflare waiting. Put the report in a background job and return a status URL promptly. Correlate the origin log with the job’s database and downstream-call timings. Cloudflare emits the 524 in this arrangement; the framework may eventually log a completed request.
- ALB or Kubernetes ingress behind Cloudflare: check the inner proxy timeout as well as Cloudflare’s. Raising an ingress read annotation or ALB idle limit cannot raise Cloudflare’s limit; it can expose the outer 524 once the earlier 504 is removed. Inspect both access logs for the same request.
Fix it
-
Find the slow request. Search origin logs for the Ray ID or the URL. Nginx: log
$request_time. Look for requests where it nears 125 seconds.log_format timed '$remote_addr "$request" $status $request_time $upstream_response_time ray=$http_cf_ray'; access_log /var/log/nginx/timed.log timed; -
Make slow endpoints asynchronous. Return 202 Accepted with a status URL, process in a queue (Sidekiq, Celery, BullMQ), and poll or push the result. Exports, reports and bulk imports are the usual offenders.
-
Fix the actual bottleneck: missing database indexes, N+1 queries, locks, a downstream API without a timeout. Add explicit timeouts to outbound calls so your service fails before Cloudflare does.
-
Test streaming through the proxy. Flush real response chunks and inspect buffering at every hop. For an nginx streaming location,
proxy_buffering off;forwards data as it arrives. Compare the direct and proxied stream before relying on it for long generation tasks. -
Bypass the proxy for heavy transfers. Large uploads, long-poll or export endpoints can use an unproxied (grey cloud) subdomain, accepting that you lose Cloudflare protection on it.
-
Raise timeouts consistently if you have to: Enterprise plan for Cloudflare, plus
proxy_read_timeout, application server timeouts (gunicorn--timeout, PHPmax_execution_time) and load balancer idle timeout, otherwise a lower layer fails first.
Reproduce
time curl -s -o /dev/null -w '%{http_code}\n' https://example.com/slow-endpoint
# 524 after ~125s
time curl -s -o /dev/null -w '%{http_code}\n' --resolve example.com:443:203.0.113.10 https://example.com/slow-endpoint
# the origin's real status and duration
524 vs related
| Code | Meaning |
|---|---|
| 522 | Could not connect (or acknowledge) in time |
| 524 | Connected, then the origin read or write timeout expired |
| 504 | A gateway timed out connecting or waiting for response data |
Related
Frequently asked questions
What does Cloudflare error 524 mean?
A 524 error means Cloudflare connected to your origin server but an origin read or write took too long. The default read timeout is 125 seconds; a separate 30-second write timeout also produces 524.
How do I fix a 524 error?
Optimize slow server-side operations, add database indexes, implement caching, use background jobs for long tasks, or upgrade to Cloudflare Enterprise for longer timeouts.
What is the difference between 522 and 524?
522 means connection establishment or acknowledgement timed out. 524 means Cloudflare connected but an origin read or write timed out.
Why does my API return status_code=524 with no body?
Use the HTTP status, CF-Ray and elapsed time to locate the timeout even when the wrapper supplies no body. Check origin logs at the same time; inspect the status before parsing JSON, and check whether a state-changing operation completed before repeating it.
Is the Cloudflare 524 read timeout 120 or 125 seconds?
Current Cloudflare documentation lists 125 seconds as the default Proxy Read Timeout. Check the configured limit for Enterprise zones and the separate 30-second write timeout when diagnosing a faster 524.
Can I increase the Cloudflare timeout?
The proxy read timeout is fixed on Free, Pro, and Business plans. Enterprise zones can raise it, up to 6,000 seconds, through the zone settings API or a Cache Rule for cacheable requests. Consider optimizing your application instead.
Sources
Related
522 Connection Timed Out
Cloudflare-specific error when unable to establish a TCP connection to the origin server. Learn how to diagnose and fix 522 timeout errors.
520 Web Server Returned an Unknown Error
Cloudflare-specific error when the origin server returns an unexpected response. Learn about 520 errors and how to troubleshoot them.
521 Web Server Is Down
Cloudflare-specific status code indicating the origin server refused the connection. Learn about this proxy error and how to troubleshoot it.
523 Origin Is Unreachable
Cloudflare-specific error when the origin server's IP address is unreachable. Learn about DNS and routing issues causing 523 errors.