Cloudflare
How to tell Turnstile, managed challenges and blocks apart
Cloudflare can answer an automated request in several different ways, and each needs a different response from you. A few checks on the status, headers and page text tell you which one you are looking at.
Why the distinction matters
"Cloudflare blocked me" covers at least four different situations. A Turnstile widget inside a form is a CAPTCHA you can answer with a token. A managed challenge in front of a whole page is a check you can pass for a cookie, from your own IP. A rate limit asks you to slow down. A firewall block is a decision by the site owner that no client can reverse. Spending money on solving in the last two cases achieves nothing, and treating the first two as blocks gives up on work that is perfectly doable.
First, is it Cloudflare at all?
Responses served through Cloudflare carry a server: cloudflare header and a cf-ray header with a request id. Inspect them with curl -sI https://example.com/ or in the browser's Network panel. If neither is present, the protection is something else, and the rest of this guide does not apply.
The signals, side by side
| What you see | Status | Key markers | What it is |
|---|---|---|---|
| Normal page with a small widget in a form | 200 | cf-turnstile element, script from challenges.cloudflare.com/turnstile | Turnstile widget |
| Full screen "Just a moment..." or "Verifying you are human" | 403 (older setups 503) | cf-mitigated: challenge header, /cdn-cgi/challenge-platform/ script | Managed or JS challenge |
| "Access denied" with Error 1020 | 403 | Error code on the page, no challenge script | Firewall rule block |
| Error 1010 | 403 | "banned your access based on your browser's signature" | Browser signature block |
| Error 1006, 1007 or 1008 | 403 | "Your IP address has been banned" | IP ban by the owner |
| Error 1015 | 429 | "You are being rate limited" | Rate limiting rule |
| Error 520 to 527 | 5xx | Cloudflare error page naming the origin | Problem between Cloudflare and the site's server |
Cloudflare's error pages put the code in the title and in a details block, so a search for Error 10 or Error 52 in the HTML is usually enough to classify them.
Cookies tell you what happened before
- __cf_bm is Cloudflare's bot management cookie. It shows up on many ordinary responses and does not mean you were challenged.
- cf_clearance appears after a challenge was passed. If you have one and still see the challenge, it has expired or no longer matches your IP or user agent; see reusing cf_clearance cookies.
- _cfuvid is used by rate limiting to tell visitors behind one IP apart. Like
__cf_bm, its presence alone means nothing bad.
A classifier you can drop into a scraper
This Python function looks at a response from any HTTP library with status_code, headers and text and returns a label. Use it to route each response to the right handling.
import re
ERROR_LABELS = {
"1020": "block-firewall-rule", "1010": "block-browser-signature",
"1006": "block-ip-ban", "1007": "block-ip-ban", "1008": "block-ip-ban",
"1015": "rate-limited",
}
def classify_cloudflare(resp) -> str:
hdr = dict((name.lower(), value) for name, value in resp.headers.items())
if "cloudflare" not in hdr.get("server", "").lower() and "cf-ray" not in hdr:
return "not-cloudflare"
body = resp.text[:200_000]
if hdr.get("cf-mitigated", "").lower() == "challenge" or "/cdn-cgi/challenge-platform/" in body:
return "challenge-page"
code = re.search(r"Error\s*(?:code\s*)?(1\d{3}|52\d)", body)
if code:
return ERROR_LABELS.get(code.group(1), "origin-error" if code.group(1).startswith("52") else "cf-error-" + code.group(1))
if "challenges.cloudflare.com/turnstile" in body or 'class="cf-turnstile"' in body:
return "turnstile-widget"
return "ok" if resp.status_code < 400 else f"http-{resp.status_code}"
The order of checks matters. Challenge pages also mention Cloudflare and can include error like text, so they are tested first. The Turnstile check comes last because a normal 200 page with a widget is otherwise indistinguishable from an ordinary page. Limiting the body to the first 200,000 characters keeps the function fast on large pages.
Which task fits which label
- turnstile-widget: read the site key and any action or cData, then use the Turnstile task. See Turnstile in Python.
- challenge-page: use the Cloudflare challenge task with your own sticky proxy and reuse the cookie. See the challenge page in Python.
- rate-limited: no task. Back off and lower the rate for that IP.
- block-*: no task. These are explicit rules. The articles on error 1020 and related codes explain what they mean and what, if anything, is in your hands.
- origin-error: no task. The site itself is having trouble; retry later.
Watch for pages that change over time
Cloudflare decisions are dynamic. The same URL can return a normal page at first, a challenge after a burst of requests, and a rate limit after that. Run the classifier on every response, not just the first, and log the label counts per site and per IP. A shift from "ok" to "challenge-page" is an early sign to slow down; a shift to "block-firewall-rule" means the site owner's rules now treat your traffic as unwanted, and continuing would be pointless and inconsiderate.
Two lookalikes worth knowing
Some responses resemble Cloudflare's but are not. A site's own maintenance page can mention Cloudflare in passing; check for cf-ray before trusting the text. And some sites run their own JavaScript checks on top of Cloudflare, with pages that look similar to a challenge but carry no cf-mitigated header and no challenge platform script. Those are the site's own code, and the Cloudflare tasks do not apply to them.
Manual checks in the browser
When you are unsure, open the URL in a normal browser from the same network. A challenge you can pass by hand confirms the challenge page. An error page with a code in a normal browser confirms a block that applies to your IP. If the browser loads the page fine but your script does not, the difference lies in the client: headers, cookies or the TLS fingerprint discussed in TLS fingerprinting.
Task fields for the two solvable cases are on the Turnstile and Cloudflare Challenge pages.
Common questions
How do I know a response came through Cloudflare?
Look for a server: cloudflare header and a cf-ray header. Without them, another system is responding.
What does the cf-mitigated header mean?
A value of challenge marks a response where Cloudflare served a challenge instead of the page.
Is a Turnstile widget the same as the challenge page?
No. The widget sits inside a site's form and returns a token; the challenge page covers the whole page and returns a cookie.
Can error 1020 be solved with a CAPTCHA task?
No. It is a firewall rule set by the site owner. No token or cookie changes it.
Does the __cf_bm cookie mean I am flagged?
No. Cloudflare sets it on many normal responses for bot management.
Keep reading
- Managed challengeCloudflare's full-page check that picks between a silent test and an interactive one, ending in a cf_clearance cookie.
- Cloudflare error 1020 Access DeniedError 1020 means a site owner's firewall rule matched your request. What it covers, what a client can change, and what it cannot.
- Cloudflare Challenge solver$0.84 per 1,000 tasks, answers under 10 seconds.
- Cloudflare Turnstile solver$0.84 per 1,000 tasks, answers under 3 seconds.