Cloudflare WAF and 5-second challenge solver
From captcha to zero.
Solve Cloudflare WAF and 5-second challenge pages to a cf_clearance cookie.
A cf_clearance for Cloudflare's managed, JavaScript and interactive challenge pages, through your proxy, charged only when solved.
Solve Cloudflare WAF and 5-second challenge pages too: a task returns the cf_clearance cookie with the user agent it was issued for.
- $0.80per 1,000, through your proxy
- $0when a task fails
- HTTP or HTTPSone fixed address, no SOCKS yet
One challenge task, in and out
Example valuesPOST /createTask · what you send
- type
CloudflareChallengeTaskCapSolver's AntiCloudflareTask works too- websiteURL
https://shop.example.com/the page behind the challenge- proxy
http://user:pass@proxy.example.net:8080the proxy you will browse with: sticky or static
POST /getTaskResult · what you get
- solution.cookies.cf_clearance
Dyw1BhDnEAGRy5fh…lets your later requests through- solution.userAgent
Mozilla/5.0 (Windows NT 10.0; Win64; x64) … Chrome/151.0.0.0 Safari/537.36send exactly this User-Agent with the cookie- cost
0.000800charged now, when the clearance is ready
Clearance readyUse the cookie, the user agent and your proxy together, or the site challenges you again.
What it solves
Cloudflare WAF, "Just a moment..." and the 5-second challenge
Three names people search for, and one page to solve: the interstitial challenge Cloudflare shows in front of a site. A CloudflareChallengeTask passes it, whatever it is called.
Cloudflare WAF challenge
A site's Cloudflare WAF rules (custom rules, rate limiting rules and IP Access rules) can answer a request with a challenge instead of the page, when the rule's action is Managed Challenge, Non-Interactive Challenge or Interactive Challenge. Bot Fight Mode and Under Attack mode show the same page.
"Just a moment..." and "Checking your browser"
The interstitial challenge page itself: a full-page screen, sent with HTTP 403 and the header cf-mitigated: challenge, that runs Cloudflare's checks before the visitor reaches the page. "Checking your browser before accessing..." is its older wording, which Cloudflare's reference still uses for Under Attack mode.
The 5-second challenge
The old name for Cloudflare's JavaScript challenge, after the few seconds its page took. Today it is a Managed Challenge or a Non-Interactive Challenge (API value js_challenge), which Cloudflare says typically takes less than five seconds.
cf_clearance
The cookie a browser earns by passing any of them. It lets that visitor through until the site's Challenge Passage time runs out, and it is what a challenge task returns.
A Cloudflare block, such as error 1020, is a refusal rather than a challenge: no task passes it. What error 1020 means
Your proxy
The proxy decides whether the clearance works
Cloudflare ties cf_clearance to the visitor that earned it: in practice its user agent and its address. So the task runs through your proxy, and you use the clearance through that same proxy.
- HTTP or HTTPS, with its port. SOCKS is not supported yet.
- One address across connections: a sticky session of a rotating provider, or a static ISP or datacenter proxy, that keeps its address for as long as you use the clearance.
- A public host, on a port no other protocol reserves. A proxy that resolves to a private address fails with
ERROR_PROXY_NOT_ALLOWED, and nothing is charged. - There is no proxyless challenge task. A CloudflareChallengeTaskProxyless is refused, and nothing is held.
- Your proxy's password is never logged, and it is deleted when the task ends.
Sticky session or static proxyClearance accepted
- Our solver earns the clearance
203.0.113.7 - Your next request
203.0.113.7
Rotating proxyChallenged again
- Our solver earns the clearance
203.0.113.7 - Your next request
198.51.100.24
The task still counts as solved and is charged: we cannot tell that your next connection leaves from somewhere else.
Check yours: ask twice, on two separate connections. The ip= line must match.
TRACE=https://www.cloudflare.com/cdn-cgi/trace
curl -s -x "$PROXY_URL" $TRACE | grep ^ip=
curl -s -x "$PROXY_URL" $TRACE | grep ^ip=Example addresses, from the documentation ranges.
The code
One request, one clearance
Create a CloudflareChallengeTask with the page's URL and your proxy, read it until it ends, then send the cf_clearance cookie with its user agent through the same proxy. The sample points at our own test page behind a managed challenge, so it runs as copied.
#!/usr/bin/env bash
# Pass this page's Cloudflare challenge through your proxy with createTask, then load the page
# with the clearance.
set -euo pipefail
API=${ZEROCAPTCHA_API:-https://api.zerocaptcha.io}
KEY=${ZEROCAPTCHA_KEY:?Set ZEROCAPTCHA_KEY to your API key, zc_live_..., from the dashboard.}
PROXY=${PROXY_URL:?Set PROXY_URL to your proxy, such as http://user:pass@proxy.example.net:8080}
PAGE=https://zerocaptcha.io/captcha-test/cloudflare-managed-challenge
# 1. createTask for this page, through the proxy you will browse with: the clearance only works
# from its address. CALLBACK_URL, when set, is called with the result when the task ends.
BODY=$(jq -n --arg key "$KEY" --arg proxy "$PROXY" --arg callback "${CALLBACK_URL:-}" '{
clientKey: $key,
task: {
type: "CloudflareChallengeTask",
websiteURL: "https://zerocaptcha.io/captcha-test/cloudflare-managed-challenge",
proxy: $proxy
},
callbackUrl: (if $callback == "" then null else $callback end)
}')
CREATED=$(curl -sS --fail-with-body "$API/createTask" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d "$BODY")
# errorId 1 is a refusal: errorCode and errorDescription say why.
if [ "$(jq -r .errorId <<<"$CREATED")" != 0 ]; then echo "$CREATED" >&2; exit 1; fi
TASK_ID=$(jq -r .taskId <<<"$CREATED")
# 2. getTaskResult every 2 seconds until the task is ready; errorId 1 means it failed, unpaid.
while :; do
sleep 2
RESULT=$(curl -sS --fail-with-body "$API/getTaskResult" \
-H "Content-Type: application/json" \
-d "$(jq -n --arg key "$KEY" --arg id "$TASK_ID" '{clientKey: $key, taskId: $id}')")
if [ "$(jq -r .errorId <<<"$RESULT")" != 0 ]; then echo "$RESULT" >&2; exit 1; fi
if [ "$(jq -r .status <<<"$RESULT")" = ready ]; then break; fi
done
CLEARANCE=$(jq -r .solution.cookies.cf_clearance <<<"$RESULT")
USER_AGENT=$(jq -r .solution.userAgent <<<"$RESULT")
# 3. Come back as the browser that passed: the same proxy, user agent and cookie. A client whose
# TLS does not look like that browser may be challenged again (use curl-impersonate).
curl -sS -o /dev/null -w "page: HTTP %{http_code}\n" \
-x "$PROXY" -A "$USER_AGENT" -b "cf_clearance=$CLEARANCE" "$PAGE"
curl -sS -x "$PROXY" -A "$USER_AGENT" -b "cf_clearance=$CLEARANCE" \
"https://zerocaptcha.io/api/v1/demo/clearance"
# Pass this page's Cloudflare challenge through your proxy with createTask, then load the page
# with the clearance.
import os
import sys
import time
import uuid
import requests
API = os.environ.get("ZEROCAPTCHA_API", "https://api.zerocaptcha.io")
PAGE = "https://zerocaptcha.io/captcha-test/cloudflare-managed-challenge"
KEY = os.environ.get("ZEROCAPTCHA_KEY") or sys.exit("Set ZEROCAPTCHA_KEY to your API key, zc_live_..., from the dashboard.")
PROXY = os.environ.get("PROXY_URL") or sys.exit("Set PROXY_URL to your proxy, such as http://user:pass@proxy.example.net:8080")
def post(path, body, headers=None):
"""POSTs JSON to the API: the reply, or an exit with the reason it was refused."""
reply = requests.post(f"{API}{path}", json=body, headers=headers or {}, timeout=30)
reply.raise_for_status()
data = reply.json()
if data.get("errorId"):
sys.exit(f"{data['errorCode']}: {data['errorDescription']}")
return data
# 1. createTask for this page, through the proxy you will browse with: the clearance only works
# from its address.
created = post(
"/createTask",
{
"clientKey": KEY,
"task": {
"type": "CloudflareChallengeTask",
"websiteURL": "https://zerocaptcha.io/captcha-test/cloudflare-managed-challenge",
"proxy": PROXY,
},
# Optional: called with the result when the task ends.
"callbackUrl": os.environ.get("CALLBACK_URL"),
},
headers={"Idempotency-Key": str(uuid.uuid4())},
)
# 2. getTaskResult every 2 seconds until the task is ready; a failed one exits, unpaid.
while True:
time.sleep(2)
result = post("/getTaskResult", {"clientKey": KEY, "taskId": created["taskId"]})
if result["status"] == "ready":
break
# 3. Come back as the browser that passed: the same proxy, user agent and cookie. A client whose
# TLS does not look like that browser may be challenged again (try curl_cffi).
session = requests.Session()
session.proxies = {"http": PROXY, "https": PROXY}
session.headers["User-Agent"] = result["solution"]["userAgent"]
session.cookies.set("cf_clearance", result["solution"]["cookies"]["cf_clearance"])
page = session.get(PAGE, timeout=30)
print("page:", page.status_code, page.headers.get("cf-mitigated", "not challenged"))
print(session.get("https://zerocaptcha.io/api/v1/demo/clearance", timeout=30).json())
// Pass this page's Cloudflare challenge through your proxy with createTask, then load the page
// with the clearance.
import { ProxyAgent, fetch as proxied } from "undici";
const API = process.env.ZEROCAPTCHA_API || "https://api.zerocaptcha.io";
const PAGE = "https://zerocaptcha.io/captcha-test/cloudflare-managed-challenge";
const KEY = process.env.ZEROCAPTCHA_KEY;
const PROXY = process.env.PROXY_URL; // such as http://user:pass@proxy.example.net:8080
if (!KEY || !PROXY) throw new Error("Set ZEROCAPTCHA_KEY to your API key and PROXY_URL to your proxy.");
/** POSTs JSON to the API: the reply, or an error with the reason it was refused. */
async function post(path, body, headers = {}) {
const reply = await fetch(`${API}${path}`, {
method: "POST",
headers: { "Content-Type": "application/json", ...headers },
body: JSON.stringify(body),
});
if (!reply.ok) throw new Error(`${path}: HTTP ${reply.status}: ${await reply.text()}`);
const data = await reply.json();
if (data.errorId) throw new Error(`${data.errorCode}: ${data.errorDescription}`);
return data;
}
// 1. createTask for this page, through the proxy you will browse with: the clearance only works
// from its address.
const { taskId } = await post(
"/createTask",
{
clientKey: KEY,
task: {
type: "CloudflareChallengeTask",
websiteURL: "https://zerocaptcha.io/captcha-test/cloudflare-managed-challenge",
proxy: PROXY,
},
// Optional: called with the result when the task ends.
callbackUrl: process.env.CALLBACK_URL,
},
{ "Idempotency-Key": crypto.randomUUID() },
);
// 2. getTaskResult every 2 seconds until the task is ready; a failed one throws, unpaid.
let result;
do {
await new Promise((resolve) => setTimeout(resolve, 2000));
result = await post("/getTaskResult", { clientKey: KEY, taskId });
} while (result.status === "processing");
// 3. Come back as the browser that passed: the same proxy, user agent and cookie. A client whose
// TLS does not look like that browser may be challenged again.
const { userAgent, cookies } = result.solution;
const dispatcher = new ProxyAgent(PROXY);
const asCleared = { "User-Agent": userAgent, Cookie: `cf_clearance=${cookies.cf_clearance}` };
const reply = await proxied(PAGE, { dispatcher, headers: asCleared });
console.log("page:", reply.status, reply.headers.get("cf-mitigated") ?? "not challenged");
const check = await proxied("https://zerocaptcha.io/api/v1/demo/clearance", { dispatcher, headers: asCleared });
console.log(await check.json());
- File
- challenge.sh 47 lines
- Needs
- bash, curl, jq and uuidgen
- Run
bash challenge.sh- Target
- Our managed challenge test page. Set PROXY_URL to your proxy.
- File
- challenge.py 59 lines
- Needs
- Python 3.10 or later and the requests package
- Run
python challenge.py- Target
- Our managed challenge test page. Set PROXY_URL to your proxy.
- File
- challenge.mjs 57 lines
- Needs
- Node.js 22 or later, and undici for the proxy
- Run
node challenge.mjs- Target
- Our managed challenge test page. Set PROXY_URL to your proxy.
{
"errorId": 0,
"taskId": "0192a6c4-7f1e-7b2a-9d41-3c5e8a10f2b7",
"status": "ready",
"solution": {
"token": "Dyw1BhDnEAGRy5fh…",
"type": "cloudflare",
"userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/151.0.0.0 Safari/537.36",
"cookies": {
"cf_clearance": "Dyw1BhDnEAGRy5fh…"
}
},
"cost": "0.000800",
"createTime": 1791537240,
"endTime": 1791537249,
"solveCount": 1,
"expiresAt": "2026-10-09T09:44:09Z"
}expiresAt is when the API stops serving the clearance, 30 minutes after it was issued; read after it, the reply is ERROR_TOKEN_EXPIRED and the task stays charged. How long the site accepts the cookie is up to the site.
{
"errorId": 0,
"taskId": "0192a6c4-7f1e-7b2a-9d41-3c5e8a10f2b7",
"status": "processing"
}Ask again in two seconds. Nothing is charged until the clearance is ready.
{
"errorId": 1,
"errorCode": "ERROR_CAPTCHA_UNSOLVABLE",
"errorDescription": "Every attempt to solve the challenge failed. Nothing was charged.",
"taskId": "0192a6c4-7f1e-7b2a-9d41-3c5e8a10f2b7",
"status": "failed",
"cost": "0.000000"
}A failed task costs nothing. The other ways a challenge task can end are below.
Reading the result
solution.cookies.cf_clearance- The cf_clearance cookie's value.
solution.tokenholds the same value. solution.userAgent- The User-Agent header to send with the cookie, exactly as given.
expiresAt- Until when the API serves the clearance: 30 minutes after it was issued. Read after that, the reply is
ERROR_TOKEN_EXPIREDand the task stays charged. How long the site accepts the cookie is up to the site. cost- What you paid, in US dollars: 0.000800 for a clearance, 0.000000 for a failed task.
In the REST API, GET /v1/tasks/{id} returns the same clearance as solution.cookie.value, with tokenExpiresAt. See the challenge pages docs.
Using the clearance
Come back as the browser that passed
- Clearance readycharged $0.0008
- Send it with every requestsame user agent, same proxy
- Challenged againcreate a new task
- Send the cookie and the user agent with each request, through the proxy that earned them. Reuse them until the site challenges you again, then create a new task.
- The site decides how long the cookie works, through its own Challenge Passage setting. Separately, the API serves the clearance for 30 minutes after it is issued, so read it within that time.
- TLS counts too. A client whose handshake does not look like the browser the user agent names may be challenged again, whatever its cookie. For sites that check, use a client that impersonates the browser, such as curl-impersonate, or a real browser.
- In a browser you drive, set the cookie for the site's domain and the browser's user agent before loading the page, and route the browser through the same proxy. Browser automation
curl "https://shop.example.com/" \
--proxy "$PROXY_URL" \
-H "User-Agent: $USER_AGENT" \
-H "Cookie: cf_clearance=$CF_CLEARANCE"// got 14, through the same proxy with hpagent.
import got from "got";
import { HttpsProxyAgent } from "hpagent";
const site = got.extend({
agent: { https: new HttpsProxyAgent({ proxy: process.env.PROXY_URL }) },
headers: { "user-agent": userAgent, cookie: `cf_clearance=${cookie.value}` },
});
const page = await site("https://shop.example.com/");
console.log(page.statusCode);import os
import httpx
import requests
proxy = os.environ["PROXY_URL"]
# requests
with requests.Session() as session:
session.proxies = {"http": proxy, "https": proxy}
session.headers["User-Agent"] = user_agent
session.cookies.set("cf_clearance", clearance, domain="shop.example.com")
print(session.get("https://shop.example.com/", timeout=30).status_code)
# httpx
with httpx.Client(proxy=proxy, headers={"User-Agent": user_agent}, cookies={"cf_clearance": clearance}) as client:
print(client.get("https://shop.example.com/", timeout=30).status_code)// Through the same proxy, with the cookie in a jar and the user agent on every request.
proxy, _ := url.Parse(os.Getenv("PROXY_URL"))
jar, _ := cookiejar.New(nil)
site, _ := url.Parse("https://shop.example.com/")
jar.SetCookies(site, []*http.Cookie{{Name: "cf_clearance", Value: task.Solution.Cookie.Value}})
client := &http.Client{
Jar: jar,
Transport: &http.Transport{Proxy: http.ProxyURL(proxy)},
Timeout: 30 * time.Second,
}
req, _ := http.NewRequest(http.MethodGet, site.String(), nil)
req.Header.Set("User-Agent", task.Solution.UserAgent)
resp, err := client.Do(req)<?php
$curl = curl_init('https://shop.example.com/');
curl_setopt_array($curl, [
CURLOPT_PROXY => getenv('PROXY_URL'),
CURLOPT_USERAGENT => $userAgent,
CURLOPT_COOKIE => 'cf_clearance=' . $clearance,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 30,
]);
$page = curl_exec($curl);
echo curl_getinfo($curl, CURLINFO_RESPONSE_CODE), PHP_EOL;- File
- 4 lines
- From
- The challenge pages docs: Use the clearance
- File
- 10 lines
- From
- The challenge pages docs: Use the clearance
- File
- 17 lines
- From
- The challenge pages docs: Use the clearance
- File
- 13 lines
- From
- The challenge pages docs: Use the clearance
- File
- 11 lines
- From
- The challenge pages docs: Use the clearance
Which task?
Challenge page or Cloudflare Turnstile widget?
Both are tasks on the same API, with the same prepaid balance and the same rule: you pay only when a task succeeds. A page that shows "Just a moment..." before any content is a challenge page.
| Question | Challenge page | Cloudflare Turnstile widget |
|---|---|---|
| Where it sits | In front of a whole site, before any content | Inside a page, usually a form |
| What you get | The cf_clearance cookie and the user agent it was issued for | A single-use token for the form |
| How long it works | Until the site challenges again, as its own Challenge Passage setting decides | Once, within 300 seconds |
| Proxy | Always yours: HTTP or HTTPS, one fixed address | Optional: proxyless, or yours with TurnstileTask |
| Task and price | CloudflareChallengeTask, $0.80 per 1,000 | TurnstileTaskProxyless, $0.40 per 1,000; TurnstileTask, $0.40 per 1,000 |
For a Cloudflare Turnstile widget, see the Cloudflare Turnstile solver.
When it fails
When a challenge task fails, nothing is charged
A challenge task that fails, or is refused, costs nothing. The reply says why, in the API's own words.
| Code and description | You pay |
|---|---|
ERROR_CAPTCHA_UNSOLVABLE"Every attempt to solve the challenge failed. Nothing was charged." | Not charged |
ERROR_TASK_TIMEOUT"The task was not solved before its deadline. Nothing was charged." | Not charged |
ERROR_PROXY_NOT_ALLOWED"The proxy points at a private or reserved address. Nothing was charged." | Not charged |
ERROR_INVALID_TASK_DATARefused at createTask when the task has no proxy: "CloudflareChallengeTask needs your proxy: Cloudflare binds a clearance to the IP address that earned it, so it must be earned through the proxy you will use it from." Nothing is held. | Not charged |
ERROR_DOMAIN_BLOCKEDRefused at createTask: "Tasks for this domain are not allowed by the Acceptable Use Policy." Nothing is held. For a task already created: "The domain was blocked before the task could run. Nothing was charged." | Not charged |
ERROR_TASK_NOT_SUPPORTEDAnswers a CloudflareChallengeTaskProxyless: a challenge task needs your proxy. Nothing is held. | Not charged |
A clearance read after its expiresAt answers ERROR_TOKEN_EXPIRED, and its task stays charged: it was solved. Every code is in the errors reference.
Learn and test
Try it on a live challenge page, then read on
Test it on a live Cloudflare WAF challenge page
A page behind each kind of Cloudflare challenge, and one with a pre-clearance widget, to point a challenge task at. Each shows whether your browser holds a cf_clearance cookie.
Cloudflare WAF and 5-second challenge guides
- Cloudflare Challenge Page vs Cloudflare Turnstile: Which Is It?Cloudflare
- The cf_clearance Cookie Explained: User Agent, IP and LifetimeCloudflare
Cloudflare challenges, errors and WAF rules
- Cloudflare WAF Bypass: What Gets an Automated Client ThroughExplainer
- Cloudflare 5-Second Challenge: What It Is Now and How to Pass ItExplainer
- Cloudflare "Just a Moment" and "Checking Your Browser" PagesTroubleshooting
- Please Unblock challenges.cloudflare.com to Proceed: FixesTroubleshooting
- Cloudflare Managed vs Non-Interactive vs Interactive ChallengeExplainer
- Cloudflare Challenge Loop: Why 'Just a moment...' RepeatsTroubleshooting
6 more
- Cloudflare Bot Management vs Turnstile vs Challenge PagesComparison
- Cloudflare Error 1020 Access Denied: What It Means for AutomationTroubleshooting
- Cloudflare Error 1015 Rate Limited: Causes and Backoff in CodeTroubleshooting
- Cloudflare WAF Rules Explained: Challenge, Block, Skip, LogExplainer
- What Is a WAF? And What a Cloudflare WAF Challenge MeansExplainer
- Playwright and Cloudflare "Just a Moment": Using cf_clearanceTutorial
FAQ
Cloudflare WAF and 5-second challenge questions
Anything else: the challenge pages docs or contact us.
Are Cloudflare WAF and 5-second challenge pages supported today?
Yes. A challenge task passes the page a Cloudflare WAF rule shows through your proxy, and returns the cf_clearance cookie with the user agent it was issued for, charged only when it succeeds.
What is the Cloudflare 5-second challenge?
The old name for Cloudflare's JavaScript challenge page, after the few seconds it took. Today a WAF rule shows a Managed or Non-Interactive Challenge in its place, which Cloudflare says typically takes less than five seconds. A challenge task solves either, and returns the cf_clearance cookie.
Is "Just a moment..." a Cloudflare WAF challenge?
Usually. "Just a moment..." is the challenge page Cloudflare shows when a WAF rule, Bot Fight Mode or Under Attack mode challenges a request. It answers with HTTP 403 and the header cf-mitigated: challenge. A block, such as error 1020, is a refusal rather than a challenge, and no task can pass it.
How is a challenge page different from Cloudflare Turnstile?
A challenge page stands in front of a whole site and, once passed, sets the cf_clearance cookie. Turnstile is a widget inside a page that gives its form a single-use token. They need different tasks.
Why must I reuse the user agent and proxy?
Cloudflare ties cf_clearance to the visitor and device it was issued to: in practice, the browser's user agent and usually its address. Requests with another user agent or from another address are challenged again.
Will I pay for challenges that fail?
No. Every ZeroCaptcha task holds its price and charges it only when it succeeds; a task that fails, or expires before it is solved, costs nothing.
ZeroCaptcha You build. We solve.
Get your first clearance
Create an account, add $10 and run your first task.