How to bypass Cloudflare bot protection when scraping public pages
Cloudflare sits in front of a large share of the web, so it is usually the first wall a scraper hits: a "Just a moment..." page, a 403 with cf-mitigated: challenge, or a flat "Access denied, error 1020". The page works in your browser and fails in your code.
This guide explains how Cloudflare tells the two apart, why the usual tricks stop working after a day, and what it takes to read public Cloudflare-protected pages reliably, with or without UnblockingAPI.
How to tell a site uses Cloudflare
Cloudflare is easy to spot: it signs almost every response it touches. Check the headers and cookies before you check the HTML.
| Signal | Where | What it means |
|---|---|---|
| server: cloudflare | Response header | The site is proxied through Cloudflare. Not a block by itself. |
| cf-ray | Response header | Request ID at Cloudflare's edge, present on every proxied response. |
| cf-mitigated: challenge | Response header | This response is a challenge, not the page. Usually with a 403. |
| Just a moment... | <title> | The managed challenge interstitial. A browser runs its checks and reloads. |
| /cdn-cgi/challenge-platform/ | Script URLs, redirects | Cloudflare's challenge scripts are running on this page. |
| __cf_bm | Cookie | Bot Management is on: Cloudflare is scoring visitors on this site. |
| cf_clearance | Cookie | Set after a challenge was passed. Tied to the browser and IP that passed it. |
| Error 1020 / 1010 / 1015 | Error page | 1020: a firewall rule blocked you. 1010: your browser signature is banned. 1015: rate limited. |
A quick check from the terminal. A plain curl request to a protected page usually gets the challenge straight away:
curl -sI "https://www.example.com/products/123" | grep -iE "^(HTTP|server|cf-)"
# HTTP/2 403
# server: cloudflare
# cf-mitigated: challenge
# cf-ray: 8f1c...-AMSHow Cloudflare decides you are a bot
Cloudflare does not use one test. Each request gets a bot score from many signals, and the site owner decides what happens below a threshold: allow, challenge or block. Most scrapers fail several of these at once.
TLS and HTTP/2 fingerprints
Before any HTTP is exchanged, the TLS handshake gives away which client library you use: the cipher order, extensions and curves form a fingerprint (JA3, now JA4). Python's requests, Node's fetch and Go's net/http each look nothing like Chrome. HTTP/2 settings and header order give a second fingerprint. A request whose User-Agent says Chrome but whose handshake says Python is flagged before the URL is even read.
IP reputation
Datacenter ranges (AWS, GCP, Hetzner, OVH) start with a poor score on many sites, and IPs that have sent bot traffic anywhere on Cloudflare's network carry that history. Residential and mobile IPs start far higher.
JavaScript checks
The managed challenge runs code in the browser that probes the environment: automation flags like navigator.webdriver, inconsistencies between the claimed browser and real APIs, canvas and WebGL output, timing. Headless Chrome with default settings fails these.
Turnstile
Cloudflare's CAPTCHA replacement. Most of the time it passes without the visitor doing anything, based on the signals above. An interactive checkbox appears only when the score is already doubtful, so seeing it at all is a sign the earlier layers went badly. More in the CAPTCHA guide.
Behaviour and rate
Requests per IP, the path a visitor takes through the site, and how fast. A visitor whose first-ever request is a deep product URL, hundreds of times a minute, does not look like a person.
What people try, and why it breaks
Copying browser headers into requests
Breaks quicklySetting a Chrome User-Agent and Accept headers changes nothing at the TLS layer, so the fingerprint mismatch gets worse, not better: you now claim Chrome with a Python handshake.
cloudscraper and similar solvers
Breaks quicklyThese libraries solved an older JavaScript challenge by re-implementing it in Python. Cloudflare's current challenges change often and check the browser environment itself, so they fail on most protected sites today.
Reusing a cf_clearance cookie
Helps, not enoughCopying cf_clearance from your browser works for a while, but only with the same IP and a matching User-Agent and fingerprint. It expires, it does not move between IPs, and it does not scale past one machine.
Headless Chrome / Puppeteer with stealth plugins
Helps, not enoughA real browser engine fixes the JavaScript layer and the TLS layer at once, and stealth plugins hide the obvious automation flags. On a datacenter IP it is still blocked by reputation, and plugins lag behind new detections.
curl-impersonate, tls-client, curl_cffi
Helps, not enoughLibraries that reproduce Chrome's TLS and HTTP/2 fingerprint get plain requests through on sites with light protection. Where the site sets a managed challenge, no plain HTTP client gets past it: something has to run the JavaScript.
Residential proxies
NecessaryNecessary for anything at volume, but not sufficient alone: a residential IP behind a Python fingerprint is still flagged.
What actually gets through
Getting through Cloudflare reliably means passing every layer at the same time, and only paying for the expensive layers when a site needs them.
- 1
Match the TLS and HTTP/2 fingerprint to the browser you claim
For plain requests use a client that reproduces a real Chrome handshake, header order included. Many Cloudflare sites run on default settings and let that through without a challenge.
- 2
Go out through a clean residential IP
Rotate between requests on different sites, but keep one IP for one session on the same site: a clearance earned on one IP is worthless on another.
- 3
Fall back to a real, unflagged browser
When the answer is a challenge, use a full browser engine whose automation traces are patched at the source, not by injected scripts. Give the non-interactive challenge a few seconds to complete and reload.
- 4
Arrive like a visitor
Load the homepage before deep links on a fresh session, keep cookies across requests, and keep the rate per IP low.
- 5
Detect challenges in 200 responses too
Challenge pages sometimes come back with a 200. Check the title and markers before you store the result, or you will parse a wall as data.
Getting past Cloudflare with UnblockingAPI
Send the URL you want. You do not pick a proxy type, a browser or a "premium" mode: the API tries a fast plain fetch with a real Chrome TLS and HTTP/2 fingerprint first, and switches to a real browser on a residential exit when the answer is a block, a challenge or an empty shell. A request that fails is not charged.
curl -G "https://api.unblockingapi.com/unblock" \
-H "X-Api-Key: $UNBLOCKINGAPI_KEY" \
--data-urlencode "url=https://www.example.com/products/123" \
--max-time 180import os, requests
r = requests.get(
"https://api.unblockingapi.com/unblock",
params={"url": "https://www.example.com/products/123"},
headers={"X-Api-Key": os.environ["UNBLOCKINGAPI_KEY"]},
timeout=180,
)
result = r.json()
if result["status"] == "succeeded":
print(result["http_response_code"], result["render_reason"])
html = result["response"] # the page itself, not the challenge
else:
print("failed, not charged:", result.get("error"))render_reason in the response says how the page was fetched: plain, fallback:challenge (the plain fetch hit a wall, so a browser took over), replay (a plain fetch carrying the session a browser earned earlier) and so on. What a site needs is learned per site, so the second request to a Cloudflare site goes straight to whatever worked.
What happens for Cloudflare specifically
- —The plain fetch already speaks Chrome's TLS and HTTP/2, so sites on light settings answer without a browser. That is the cheap, fast path (
render_reason: "plain"). - —A
cf-mitigated: challenge, "Just a moment..." or a 403 switches the request to a browser (fallback:challengeorfallback:blocked). The browser is a patched Firefox, not headless Chrome with plugins, on a residential exit. - —Cloudflare's non-interactive page is given a few seconds to finish and reload into the real document before a 403 is believed. Failing it at the first byte, as most tools do, throws away exits that would have been let through.
- —Once a browser has passed, its cookies can be replayed on later plain fetches to the same site through the same exit, so you do not pay for a full browser every time (
render_reason: "replay"). - —An exit that got challenged on a site is rested from that site for 30 minutes, so retries do not keep hitting the same wall.
- —UnblockingAPI does not send CAPTCHAs to solving services. A visible, interactive check that has not passed within about eight seconds means that exit has been judged; the attempt is dropped and retried on a different exit, inside the same request.
wait_for with a CSS selector of the content, or scroll_steps for lists that grow as you scroll. See the API docs for every option.When it still fails
No tool gets through every Cloudflare configuration every time, and anyone who promises 100% is guessing. The honest limits:
- —Sites with "I'm Under Attack" mode or a rule that challenges every visitor interactively. Turnstile then depends on the score of each exit, and some requests will fail.
- —Firewall rules that block whole countries or ASNs (error 1020 for everyone from there). Pick a
locationthe site serves. - —Anything behind a sign-in. If a page needs an account, it is not a public page and is out of scope, both technically and under the Acceptable Use Policy.
- —If every attempt inside the request's budget is blocked, you get
status: "failed"and the request costs nothing. You only pay for pages that came back.
Responsible use
Frequently asked questions
Cloudflare is a delivery and security service, not a legal barrier. Reading public pages is generally lawful in most places, but what you collect and how you use it is governed by local law and sometimes contract. Don't access accounts, collect personal data without a legal basis, or overload the site. When in doubt, ask a lawyer about your specific case.
Your browser passes Cloudflare's TLS fingerprint, IP reputation and JavaScript checks. Python requests, axios or Go's HTTP client fail at least the fingerprint check, and often the IP check too, so Cloudflare answers with a challenge or a block. Changing headers alone does not fix it.
On most protected sites, no. It was written for an older challenge. Current managed challenges check the browser environment itself, which a Python reimplementation cannot reproduce.
Briefly, from the same IP and with the same User-Agent and fingerprint. It expires and is bound to the client that earned it, so it does not work as a scaling strategy.
"Access denied": a firewall rule the site owner wrote matched your request. It is often a country, ASN or user-agent rule. A different location or a cleaner fingerprint may help; if the rule blocks everyone from your region, only an exit elsewhere does.
No. Many Cloudflare sites let a request with a correct Chrome TLS fingerprint through without a challenge. UnblockingAPI tries that first and only renders when the answer is a challenge, which keeps most requests fast. See JavaScript-rendered pages for when a browser is needed for other reasons.
Try a Cloudflare-protected URL.
Test the fetching layer before building your parser. Start with 500 free credits and no credit card. See pricing for credits from €5, with no subscription.
One successful request is one credit. No multipliers for rendering, proxies or retries.
Other anti-bot systemsHow anti-bot systems work
DataDome
captcha-delivery.com, the datadome cookie, device checks and why deep links get blocked.
Akamai Bot Manager
_abck and bm_sz cookies, sensor data, "Access Denied" reference pages and sec-cpt.
PerimeterX (HUMAN)
"Press & Hold", _px3 and _pxhd cookies, and why a vendor tag is not a block.
Kasada
x-kpsdk headers, ips.js and proof-of-work: a defence with no CAPTCHA to look at.
AWS WAF Bot Control
aws-waf-token, challenge.js and the 202/405 responses AWS WAF sends instead of the page.
CAPTCHAs (reCAPTCHA, hCaptcha, Turnstile)
Why the best way past reCAPTCHA, hCaptcha and Turnstile is not to be shown one.
