CloudflareBypassForScraping usually stops working for one of three reasons: you run an old build (the engine has changed three times since 2025, so last year's tutorials and errors no longer match), the browser pool cannot clear the challenge from your IP, or the returned cf_clearance is replayed with a different User-Agent, IP or TLS fingerprint. Pull the current v3 Docker image, use one sticky proxy for the solve and your requests, send the returned user_agent, and replay with curl_cffi or mirror mode.
The project (sarperavci/CloudflareBypassForScraping, roughly 2,700 stars, MIT licence, last pushed 2026-11-28) is a self-hosted server that returns Cloudflare clearance cookies, rendered HTML or Turnstile tokens. Below: how v3.0 works, how to identify your version from the error, fixes with code, and when an API is the better trade.
Quick answer: match your error to the fix
Most CloudflareBypassForScraping failures show one of these messages or symptoms. Find yours, then read the matching section below for code.
- Attempt 5: Verification page detected. Trying to bypass... (repeating forever)
- You are running the legacy CloudflareBypasser class, which retries without limit by default. Pass max_retries, run headed from a cleaner IP, or move to the v3 server.
- {"detail":"Failed to bypass Cloudflare protection"}
- HTTP 500 from /cookies or /html: the browser pool did not clear the challenge in time. Use a sticky residential proxy, set CF_LOCALE to its region, retry with bypassCookieCache=true, and check /browsers.
- cf_clearance from /cookies, but requests still gets 403 or "Just a moment..."
- The cookie is replayed with a different User-Agent, IP or TLS fingerprint. Send the returned user_agent through the same proxy with curl_cffi impersonate="chrome", or use mirror mode.
- {"detail":"x-hostname header is required for request mirroring"}
- Any path that is not a built-in endpoint is treated as a mirrored request. Send x-hostname as a bare host (example.com, not https://example.com), or call /cookies with ?url=.
- {"detail":"Invalid or unsafe URL - localhost and private IPs are not allowed"}
- The SSRF guard blocks localhost and private-network targets. Target a public hostname: localhost and private IP ranges are refused by design.
- {"detail":"Missing or invalid x-auth-token header"} (401)
- The server was started with --auth-token or CF_AUTH_TOKEN. Add x-auth-token to every request, including /browsers and mirrored ones.
- Page.goto: Timeout 10000ms exceeded / Failed to get Cloudflare clearance cookies
- Usually an old Camoufox-era image, or a proxy that rotates its IP on every request (issue #115). Pull the current latest image and switch to a fixed-IP or sticky-session proxy.
- geoip2 is required for geoip=True / Looks like you launched a headed browser without having a XServer running.
- Errors from the mid-2026 CloakBrowser and Playwright builds (issues #125 and #123). Pull the v3 image; for a manual install, add --headless or use xvfb-run.
Messages are quoted from the project's source (cf_bypasser/server/routes.py, app.py, core/mirror.py), the legacy CloudflareBypasser.py and the GitHub issues cited, all checked on 2026-12-01.
How CloudflareBypassForScraping works in 2026 (version 3.0)
Version 3.0, merged on 2026-10-25, runs a FastAPI server on port 8000 backed by a reusable pool of headless Brave browsers driven by DrissionPage (pinned to DrissionPage >=4.1.1.4,<4.2). Each request borrows a browser in its own disposable context, so every request can use a different proxy. Non-interactive challenges resolve on their own; interactive checkboxes are found in the shadow DOM and clicked.
The repository has no GitHub Releases; the Docker image ghcr.io/sarperavci/cloudflarebypassforscraping:latest is built for linux/amd64 and linux/arm64.
- /cookies?url=...&proxy=... returns cf_clearance and the exact user_agent that earned it. The README is explicit: send both together or Cloudflare rejects the cookie.
- /html returns the rendered page; /fetch returns raw bytes (PDFs, images, JSON) fetched from inside the cleared page.
- Mirror mode: any other path plus an x-hostname header. The server gets cookies, then replays your exact request with curl_cffi impersonating Chrome's TLS fingerprint.
- /turnstile?url=...&sitekey=... (added 2026-11-02) returns a Turnstile token from a widget-only page.
- /browsers reports the pool state.
Which version are you running? The error tells you
Many "not working" reports mix generations: a 2024 tutorial, a 2025 image, the 2026 README. The commit history shows four engines, each with its own error vocabulary.
- 2023 to mid-2026, legacy class: CloudflareBypasser.py plus test.py, DrissionPage driving Chrome. Logs: "Attempt 1: Verification page detected..." and "Error clicking verification button" (issues #73, #101).
- Late 2025 to June 2026: a Camoufox and playwright-captcha server. Logs mention Camoufox, LeakWarning, Page.goto timeouts and NS_ERROR_NET_INTERRUPT (issues #104, #107, #115).
- June to October 2026: CloakBrowser (migrated on 2026-06-18; the legacy DrissionPage code was removed on 2026-06-20). The geoip2 error in issue #125 belongs here.
- Since 2026-10-25, v3.0: DrissionPage with a headless Brave pool. Errors are JSON details such as "Failed to bypass Cloudflare protection".
Why it breaks
- IP reputation. In issue #115 the maintainer traced repeated timeouts to a rotating proxy that changed IP on every request, so Cloudflare never built trust, and recommended a fixed IP.
- Headless detection. The Docker image runs Brave headless (CF_HEADLESS=true), and server.py's own help text for --headless warns that "Cloudflare may detect it".
- Cookie binding. cf_clearance is tied to the User-Agent and IP that solved the challenge; the docs note that a changed exit IP invalidates it.
- Locale mismatch. A browser language that does not match the proxy's country is a signal; v3 added CF_LOCALE for it.
- Resources. Each headless Brave takes about 200 to 400 MB (docker-compose.yml); too little memory or shared memory crashes browsers and times out jobs.
Fix 1: run the v3 server correctly (Docker and manual)
Use the current image with the memory the compose file asks for (4 GB limit, shm_size 2g). Caching is off by default: without CF_CACHE_ENABLED=true or --enable-cache, every request solves a fresh challenge, which is slow and burns IP reputation. Set CF_AUTH_TOKEN and bind to 127.0.0.1, because the server fetches whatever URL it receives.
A manual install needs Brave (or CF_BROWSER_PATH). Outside Docker the browser runs headed by default, so a Linux server without a display needs --headless or xvfb-run; the reporter of issue #123 fixed a boot service by switching to Docker. The Podman "exec format error" in issue #114 predates v3's multi-arch images.
# Current image (v3.0: a pool of headless Brave browsers driven by DrissionPage).
# Bind to localhost and set a token: the server fetches any URL it is sent.
docker pull ghcr.io/sarperavci/cloudflarebypassforscraping:latest
docker run -d --name cf-bypass \
-p 127.0.0.1:8000:8000 \
--shm-size=2g --memory=4g \
-e CF_AUTH_TOKEN=change-me \
-e CF_CACHE_ENABLED=true \
-e CF_LOCALE=en-US \
ghcr.io/sarperavci/cloudflarebypassforscraping:latest --browsers 3
# Is the browser pool up?
curl -H "x-auth-token: change-me" http://localhost:8000/browsers
# No semver tags were on the registry on 2026-12-01: record the digest that works
docker inspect --format '{{index .RepoDigests 0}}' \
ghcr.io/sarperavci/cloudflarebypassforscraping:latest
# Manual install instead (needs Brave; set CF_BROWSER_PATH if not auto-detected)
pip install -r server_requirements.txt
python server.py --browsers 3 --enable-cache # headed: needs a display
xvfb-run -a python server.py --browsers 3 --enable-cache # Linux server without a displayFix 2: "Failed to bypass Cloudflare protection" and timeouts
This 500 means the browser did not end up with clearance before the job ended. Work through the causes in order:
- Proxy: use a fixed-IP or sticky-session proxy (proxy= on /cookies, x-proxy for mirror mode), starting with http://, https://, socks4:// or socks5://. An unreachable proxy fails; it never falls back to a direct connection.
- Rotating pools: set CF_IP_CHECK_ENABLED=true so a changed exit IP triggers fresh cookies.
- Locale: set CF_LOCALE to the proxy's region (en-US by default).
- Timeouts: CF_CHALLENGE_TIMEOUT (30 s) limits checkbox polling and CF_JOB_TIMEOUT (120 s) how long a request holds a browser, after which the log says "exceeded 120s; restarting that browser".
- Stale cookies: bypassCookieCache=true on /cookies or x-bypass-cache: true on a mirrored request forces a fresh solve.
- Still failing on one site from a clean residential IP: the site is scoring the headless browser itself, and retries will not help.
Fix 3: cookies work in the server but not in your code
If /cookies returns cf_clearance and your client still gets a 403 or "Just a moment...", the replay is the problem. Send the returned user_agent verbatim, use the proxy you passed to /cookies, and use a client with a Chrome TLS fingerprint, as the project's own curl_cffi example does; mirror mode does this server-side. Our cf_clearance cookie guide explains what the cookie is bound to, and curl_cffi Cloudflare 403 covers fingerprint mismatches.
One caveat from issue #119: some sites keep checking with JavaScript after clearance, so a pure HTTP replay fails even with correct cookies. For those, use /html or /fetch, which run inside the browser.
# pip install curl_cffi
from curl_cffi import requests
SERVER = "http://localhost:8000"
AUTH = {"x-auth-token": "change-me"} # only if the server runs with CF_AUTH_TOKEN
TARGET = "https://protected-site.example/"
PROXY = "http://user:pass@sticky-proxy.example.com:8080" # sticky exit IP, no per-request rotation
# 1) Clearance cookies earned through the proxy you will scrape with
r = requests.get(
f"{SERVER}/cookies",
params={"url": TARGET, "proxy": PROXY},
headers=AUTH,
timeout=180,
)
r.raise_for_status()
data = r.json() # {"cookies": {"cf_clearance": "..."}, "user_agent": "..."}
# 2) Replay: same cookies, same User-Agent, same proxy, Chrome TLS fingerprint
s = requests.Session(impersonate="chrome", proxies={"http": PROXY, "https": PROXY})
s.headers["User-Agent"] = data["user_agent"]
s.cookies.update(data["cookies"])
page = s.get(TARGET, timeout=30)
print(page.status_code, page.headers.get("cf-mitigated"))
# Or let the server replay it (mirror mode): the path goes to the x-hostname host
m = requests.get(
f"{SERVER}/products?page=2",
headers={**AUTH, "x-hostname": "protected-site.example", "x-proxy": PROXY},
timeout=180,
)
print(m.status_code, len(m.content))Fix 4: the legacy CloudflareBypasser class loops forever
The original class only checks whether the title still contains "just a moment", clicks the checkbox and sleeps two seconds. Its default max_retries=-1 never stops, which is why logs fill with "Attempt N: Verification page detected". Cap the retries, run headed, and treat a persistent loop as an IP or fingerprint problem, not a code bug. DrissionPage-level problems are covered in DrissionPage not working on Cloudflare.
# Legacy DrissionPage class (2023 to mid-2026). It was removed from the repo
# in June 2026; this only applies if you vendored CloudflareBypasser.py.
from DrissionPage import ChromiumOptions, ChromiumPage
from CloudflareBypasser import CloudflareBypasser
options = ChromiumOptions() # headed by default; on a server run under xvfb-run
driver = ChromiumPage(options)
driver.get("https://protected-site.example/")
# The default max_retries=-1 never gives up: cap it so a blocked IP fails fast
cf = CloudflareBypasser(driver, max_retries=5, log=True)
cf.bypass()
if "just a moment" in driver.title.lower():
raise RuntimeError("still on the challenge page: change IP or move to the v3 server")
print({c["name"]: c["value"] for c in driver.cookies()}.get("cf_clearance"), driver.user_agent)
driver.quit()When to switch to an API
CloudflareBypassForScraping fits when you control the host, run moderate volume and can keep a browser pool healthy. It becomes the wrong layer when a site still fails from a clean proxy after these fixes, when you size servers at 200 to 400 MB per browser just to get one cookie per site, or when each engine change means re-testing your pipeline. If you are weighing other self-hosted tools, see our comparison of open-source Turnstile and Cloudflare solvers and cf-clearance-scraper not working.
A managed solver replaces only the challenge step: it returns cf_clearance and the matching User-Agent over HTTP, and the rest of your scraper stays the same. Only automate sites you own or are explicitly authorised to access, and respect their terms and rate limits.
NSLSolver example: cf_clearance without a browser pool
NSLSolver's Cloudflare Challenge solver API takes the page url, the challenge site_key and your proxy, and returns cookies (including cf_clearance) plus the user_agent to replay through the same proxy, solved server-side with no browser on either side. Leave user_agent out of the request: the clearance is issued for the solver's iPhone Safari browser. Challenge solves take about 3.3 s on average and cost $1.00 per 1,000 (pricing); failed solves (503) are not billed, and sign-ups with Google, Gmail or Proton get free trial credit, no card.
For a Turnstile widget on a form, use type turnstile with site_key and url (about 250 ms, $0.80 per 1,000) and submit the token as cf-turnstile-response. NSLSolver does not solve reCAPTCHA v2, hCaptcha, image CAPTCHAs or DataDome.
import requests
API_KEY = "nsl_YOUR_API_KEY"
TARGET = "https://protected-site.example/"
PROXY = "http://user:pass@sticky-proxy.example.com:8080" # same exit IP for solve AND replay
SITE_KEY = "0x4AAAAAAA..." # the challenge widget id (0x...) from the challenge page
# 1) One HTTP call replaces the browser pool: no Brave, no Docker, no Xvfb
resp = requests.post(
"https://api.nslsolver.com/solve",
headers={"X-API-Key": API_KEY},
json={
"type": "challenge",
"url": TARGET,
"site_key": SITE_KEY,
"proxy": PROXY,
# user_agent omitted: the clearance is issued for the solver's iPhone
# Safari browser, and the matching UA comes back in the response
},
timeout=120,
)
resp.raise_for_status()
data = resp.json()
# 2) Replay cf_clearance with the returned user_agent through the SAME proxy
session = requests.Session()
session.proxies = {"http": PROXY, "https": PROXY}
session.cookies.update(data["cookies"]) # includes cf_clearance
session.headers["User-Agent"] = data["user_agent"]
page = session.get(TARGET, timeout=30)
print(page.status_code, page.headers.get("cf-mitigated"))Related guides
- Cloudflare Challenge solver API: cf_clearance and the user_agent from one call.
- DrissionPage not working on Cloudflare: the library v3.0 is built on, with its own errors and fixes.
- FlareSolverr not working in 2026: the other self-hosted cookie server, and why it times out.
- The cf_clearance cookie explained: what binds it to IP and User-Agent, and how to reuse it.
- NSLSolver pricing: pay per successful solve, free credit with Google, Gmail or Proton sign-up.
Sources (checked 2026-12-01)
- CloudflareBypassForScraping README (v3.0, endpoints, mirror mode, Turnstile)
- docs/USAGE.md (installation, Docker, control headers, server.py flags)
- docs/CONFIGURATION.md (CF_* environment variables, proxies, caching)
- docker-compose.yml (memory limit, shm_size, Brave memory per browser)
- cf_bypasser/server/routes.py (error responses)
- Commit history (v3.0 merge, CloakBrowser migration, legacy removal)
- Legacy CloudflareBypasser.py (max_retries=-1 loop), commit 99070f3
- Issue #115: timeouts with a rotating proxy
- Issue #119: 403, mirror paths and cookie reuse
- Issue #125: geoip2 error in the CloakBrowser-era image