How to Fix the Cloudflare 524 Error Code (A Timeout Occurred)
Cloudflare's exact time limits, what a visitor can do, and polling code for requests that run long.
Updated
TL;DR
A 524 error code means Cloudflare connected to the website's server, but the server sent no HTTP response within 125 seconds, Cloudflare's default limit. Visitors can only try again in a few minutes; the owner has to speed the request up or run it in the background.
What error 524 looks like
Captured from Cloudflare's own 524 preview page; a site with a custom error page shows that instead.
| Where | What you see |
|---|---|
| Browser tab title (Cloudflare's default page) | example.com | 524: A timeout occurred |
| Browser page, advice for the site owner | Contact your hosting provider; check for long-running processes or an overloaded web server. / Use status polling of large HTTP processes to avoid this error. |
| Browser page, under What happened? | The origin web server timed out responding to this request. The likely cause is an overloaded background task, database or application, stressing the resources on the host web server. |
| curl with default headers | error code: 524 |
| JSON reply (curl --compressed -H 'Accept: application/json') | "title":"Error 524: A timeout occurred" / "error_name":"origin_response_timeout" / "retryable":true,"retry_after":120,"owner_action_required":true |
| Python urllib | urllib.error.HTTPError: HTTP Error 524: <none> |
| Node.js fetch() (res.status, res.statusText) | 524 <none> |
Why this happens
Cloudflare passed your request to the site's server and gave up waiting for the answer.
Often one request asks for more work than the server can finish in time, such as a large data query or export. A server short of resources also fails to answer in time.
Diagnose your 524 first
The first two need only a browser; the rest are for developers and site owners.
Open another page on the site; if it loads, the server is up and only that one request is slow.
Recall how long the page hung; about two minutes means the server went silent, half a minute that Cloudflare could not finish sending the request.
Time it with curl --max-time 150 -o /dev/null -w '%{http_code} %{time_total}'; a 524 at about 125 seconds means the site keeps Cloudflare's default limit.
Repeat it with curl --compressed -H 'Accept: application/json'; error_name origin_response_timeout in the reply confirms Cloudflare wrote the 524, not your proxy.
As the owner, open Speed > Origin Analytics; if P95 origin response time nears the timeout line, Top endpoints lists the paths that are slow.
Solutions ranked by effectiveness
Card one is for visitors, two for the site's owner, three for scripts.
- Most common fix
Retry in a few minutes, not sooner
Applies when the site is not yours. Cloudflare's 524 page asks visitors to try again in a few minutes, because the delay is on the site's server.
Check for a confirmation before resubmitting a form; the server may still have finished it.
Reload once, and stop if the 524 comes back.
Then send the site's owner the URL, the time and the Ray ID.
- Site owners
Move long work out of the request
Applies when the site is yours. Cloudflare's advice is to stop one HTTP request from waiting on a large job.
Answer 202 Accepted with a status URL, then finish the job in the background.
Put tasks that must run past 125 seconds on a DNS-only subdomain.
Ask your host to rule out a long-running process or an overloaded server.
- For developers
Start the job, then poll its status
Applies when the API you call offers background jobs or exports. One short request starts the job; later ones ask for its status.
import json, time, urllib.parse, urllib.request api = "https://api.example.com/exports" start = urllib.request.Request(api, method="POST") with urllib.request.urlopen(start, timeout=30) as res: status_url = urllib.parse.urljoin(api, res.headers["Location"]) while True: with urllib.request.urlopen(status_url, timeout=30) as res: job = json.load(res) if job["status"] != "running": break time.sleep(5) print(job)
Stop the 524 from coming back
Server-side habits first; the last item is for scripts that call slow sites.
Log each request's response time on your server, $request_time in nginx or %D in Apache, to spot slow URLs early.
On Enterprise plans, raise the limit one second past your target; Cloudflare notes the 524 can fire a second off.
With Cloudflare Tunnel, set cloudflared's origin timeouts as well; when both layers apply, the shorter one wins.
Treat a DNS-only subdomain as unprotected: its record answers with your server's real IP address.
In scripts, wait out the Retry-After header, 120 seconds on Cloudflare's 524 page, and cap your attempts.
Related errors
Learn more
FAQ
Watch your average request duration
The ISP Proxies Statistics tab can show total requests, success rate and average duration.


