Explainers

How Cloudflare Challenge Works

When Cloudflare suspects a visitor is a bot, it shows a full-page interstitial with the message "Checking your browser before accessing..." or "Verify you are human." This is called a Cloudflare Challenge — not to be confused with Turnstile, which is a widget embedded within a page.

The challenge blocks access to the entire page until the browser passes verification. Once passed, Cloudflare sets a cf_clearance cookie that grants access to subsequent requests.


How the challenge flow works

Request → Cloudflare proxy → Suspicious? → Challenge page
                                              ↓
                                    Browser verification
                                              ↓
                                    cf_clearance cookie set
                                              ↓
                                    Original page loads
  1. Request intercepted — Cloudflare's reverse proxy evaluates the incoming request
  2. Risk assessment — IP reputation, request headers, TLS fingerprint, and behavior are analyzed
  3. Challenge served — If suspicious, a challenge page replaces the intended response
  4. Browser verification — JavaScript challenges run in the browser
  5. Cookie set — On success, cf_clearance cookie is set with a configurable TTL
  6. Access granted — The browser reloads and receives the original page content

What triggers a Cloudflare Challenge

Trigger Description
Datacenter IP Request from known hosting providers
Missing headers Missing or unusual HTTP headers
TLS fingerprint JA3/JA4 fingerprint matches known bot signatures
High request rate Too many requests from the same IP
Security level setting Site owner sets challenge threshold to high
Country-based rules Geographic blocking or challenge rules
Bot score Cloudflare's ML bot score is too low
Known threat IP appears on threat intelligence lists

After passing the challenge, the browser receives:

cf_clearance=abc123...; path=/; domain=.example.com; secure; HttpOnly; SameSite=None

Key properties:

  • Duration: 15 minutes to 24 hours (configurable by site owner)
  • Scope: Tied to the specific domain
  • Binding: Bound to the user agent and IP address used during verification
  • Usage: Must be included in all subsequent requests to avoid re-challenge

Important: The cf_clearance cookie is bound to the specific User-Agent and IP address used during verification. Changing either will invalidate the cookie.


Cloudflare Challenge vs Turnstile vs JS Challenge

Feature CF Challenge Turnstile JS Challenge
Type Full-page interstitial In-page widget Silent check
User sees "Checking your browser" page Checkbox or nothing Nothing
Blocks page access Yes No Briefly
Sets cf_clearance Yes Sometimes Yes
Requires proxy to solve Yes No N/A
Site uses Cloudflare CDN Required Optional Required

Solving Cloudflare Challenge with CaptchaAI

Cloudflare Challenge solving requires a proxy because the cf_clearance cookie is bound to the IP address.

Python

import requests
import time

API_KEY = "YOUR_API_KEY"

# Submit task — proxy is REQUIRED
response = requests.get("https://ocr.captchaai.com/in.php", params={
    "key": API_KEY,
    "method": "cloudflare_challenge",
    "pageurl": "https://example.com/protected-page",
    "proxy": "username:password@proxy.example.com:8080",
    "proxytype": "HTTP",
    "json": 1
})

task_id = response.json()["request"]

# Poll for result
for _ in range(60):
    time.sleep(5)
    result = requests.get("https://ocr.captchaai.com/res.php", params={
        "key": API_KEY, "action": "get", "id": task_id, "json": 1
    }).json()

    if result.get("status") == 1:
        solution = result["request"]
        # solution contains cf_clearance cookie + user_agent
        print(f"cf_clearance: {solution}")
        break

Node.js

const axios = require('axios');

async function solveCloudflareChallenge(pageurl, proxy) {
  const { data } = await axios.get('https://ocr.captchaai.com/in.php', {
    params: {
      key: 'YOUR_API_KEY',
      method: 'cloudflare_challenge',
      pageurl,
      proxy,
      proxytype: 'HTTP',
      json: 1
    }
  });

  const taskId = data.request;

  for (let i = 0; i < 60; i++) {
    await new Promise(r => setTimeout(r, 5000));
    const res = await axios.get('https://ocr.captchaai.com/res.php', {
      params: { key: 'YOUR_API_KEY', action: 'get', id: taskId, json: 1 }
    });
    if (res.data.status === 1) return res.data.request;
  }
  throw new Error('Timeout');
}
# After getting the solution
cf_clearance = solution["cf_clearance"]
user_agent = solution["user_agent"]

# Use the SAME proxy and user agent for subsequent requests
session = requests.Session()
session.cookies.set("cf_clearance", cf_clearance, domain=".example.com")
session.headers["User-Agent"] = user_agent
session.proxies = {"https": "http://username:password@proxy.example.com:8080"}

# Now access the protected page
page = session.get("https://example.com/protected-page")
print(f"Status: {page.status_code}")

Why proxy is required

The cf_clearance cookie is cryptographically bound to:

  1. IP address — The solve must happen from the same IP you will use
  2. User-Agent — The solve user agent must match your requests
  3. TLS fingerprint — Some configurations also check TLS characteristics

If any of these differ between the solve and your subsequent requests, the cookie is invalid.


FAQ

How long does cf_clearance last?

Site owners configure the duration, typically 15 minutes to 24 hours. After expiry, a new challenge must be solved.

Can I reuse cf_clearance across different IPs?

No. The cookie is bound to the IP used during verification. Changing IPs requires a new solve.

What is the difference between Cloudflare Challenge and Turnstile?

Cloudflare Challenge is a full-page interstitial that blocks page access. Turnstile is a widget embedded within the page, similar to reCAPTCHA. Challenge requires the site to use Cloudflare as a proxy; Turnstile can be used on any site.

How long does solving take?

Cloudflare Challenge solving takes 20–60 seconds, longer than Turnstile or reCAPTCHA because of the full browser verification.

What if the page has both Cloudflare and reCAPTCHA?

Solve the Cloudflare Challenge first to access the page, then solve the reCAPTCHA on the loaded page.


Discussions (0)

No comments yet.

Related Posts

Reference CAPTCHA Token Injection Methods Reference
Complete reference for injecting solved CAPTCHA tokens into web pages.

Complete reference for injecting solved CAPTCHA tokens into web pages. Covers re CAPTCHA, Turnstile, and Cloud...

Automation Python reCAPTCHA v2
Apr 08, 2026
Comparisons Cloudflare Managed Challenge vs Interactive Challenge
Understand the difference between Cloudflare's Managed Challenge and Interactive Challenge, how each works, and the best approach for solving them.

Understand the difference between Cloudflare's Managed Challenge and Interactive Challenge, how each works, an...

Automation Migration Cloudflare Challenge
Mar 31, 2026
API Tutorials Proxy Authentication Methods for CaptchaAI API
Configure proxy authentication with Captcha AI — IP whitelisting, username/password, SOCKS 5, and passing proxies directly to the solving API.

Configure proxy authentication with Captcha AI — IP whitelisting, username/password, SOCKS 5, and passing prox...

Automation Python reCAPTCHA v2
Mar 09, 2026
API Tutorials How to Solve Cloudflare Challenge Using API
Handle the Cloudflare Challenge page using Captcha AI API.

Handle the Cloudflare Challenge page using Captcha AI API. Get a valid cf_clearance cookie with Python, Node.j...

Automation Cloudflare Challenge
Mar 25, 2026
Reference Chrome DevTools Protocol + CaptchaAI: Low-Level CAPTCHA Automation
Use Chrome Dev Tools Protocol (CDP) directly for CAPTCHA automation with Captcha AI — handleing Web Driver detection, intercepting network requests, and injecti...

Use Chrome Dev Tools Protocol (CDP) directly for CAPTCHA automation with Captcha AI — handleing Web Driver det...

Automation Python reCAPTCHA v2
Jan 12, 2026
Getting Started CaptchaAI Proxy Configuration Guide
Complete guide to configuring proxies for Captcha AI.

Complete guide to configuring proxies for Captcha AI. Covers proxy formats, types (HTTP, SOCKS 5), authenticat...

Automation Python reCAPTCHA v2
Mar 14, 2026
Explainers Cloudflare Challenge Page Session Flow: Complete Walkthrough
A step-by-step walkthrough of the Cloudflare challenge page session flow — from initial block to cf_clearance cookie, including every HTTP request, redirect, an...

A step-by-step walkthrough of the Cloudflare challenge page session flow — from initial block to cf_clearance...

Automation Cloudflare Challenge
Feb 21, 2026
Troubleshooting Cloudflare Challenge Errors and Fixes
Fix common Cloudflare Challenge solving errors.

Fix common Cloudflare Challenge solving errors. Covers cf_clearance failures, proxy issues, token expiry, and...

Automation Cloudflare Challenge
Jan 27, 2026
API Tutorials How to Solve Cloudflare Challenge with Python
Solve Cloudflare Challenge pages using Python and Captcha AI API.

Solve Cloudflare Challenge pages using Python and Captcha AI API. Complete guide with proxy setup, cf_clearanc...

Automation Python Cloudflare Challenge
Feb 01, 2026
Explainers How to Handle Cloudflare Under Attack Mode
Cloudflare's "I'm Under Attack Mode" (IUAM) is a DDo S defense that forces every visitor through a 5-second Java Script challenge before accessing the site.

Cloudflare's "I'm Under Attack Mode" (IUAM) is a DDo S defense that forces every visitor through a 5-second Ja...

Automation Cloudflare Challenge
Mar 16, 2026
Explainers How BLS CAPTCHA Works: Grid Logic and Image Selection
Deep dive into BLS CAPTCHA grid logic — how images are arranged, how instructions map to selections, and how Captcha AI processes BLS challenges.

Deep dive into BLS CAPTCHA grid logic — how images are arranged, how instructions map to selections, and how C...

Automation BLS CAPTCHA
Apr 09, 2026
Explainers Browser Fingerprinting and CAPTCHA: How Detection Works
How browser fingerprinting affects CAPTCHA challenges, what signals trigger CAPTCHAs, and how to reduce detection with Captcha AI.

How browser fingerprinting affects CAPTCHA challenges, what signals trigger CAPTCHAs, and how to reduce detect...

reCAPTCHA v2 Cloudflare Turnstile reCAPTCHA v3
Mar 23, 2026
Explainers GeeTest v3 Challenge-Response Workflow: Technical Deep Dive
A technical deep dive into Gee Test v 3's challenge-response workflow — the registration API, challenge token exchange, slider verification, and how Captcha AI...

A technical deep dive into Gee Test v 3's challenge-response workflow — the registration API, challenge token...

Automation Testing GeeTest v3
Mar 02, 2026