Skip to content
Guide

curl_cffi Cloudflare 403: Why impersonate="chrome" Isn't Enough and How to Fix It

NSLSolver TeamPublished Updated 9 min read

If curl_cffi still returns 403 with a "Just a moment..." page even with impersonate="chrome", the impersonation is probably working; it just isn't the problem. curl_cffi copies a browser's TLS/JA3 and HTTP/2 fingerprint, but it has no JavaScript engine, so it cannot pass the JavaScript challenge Cloudflare served you. Check the response for the header cf-mitigated: challenge: if it is there, you need a cf_clearance cookie from something that runs the challenge, replayed with the same User-Agent, the same IP and a matching impersonate target; if it is not, fix your target, headers and proxy.

Below: the exact symptoms and what they mean, a short script that shows which layer is blocking you, the fixes inside curl_cffi itself, and how to plug in a cf_clearance cookie when a challenge is unavoidable. curl_cffi behaviour quoted here comes from its README and docs (checked 2026-12-01).

Quick answer: what your curl_cffi result means

The same 403 status hides very different causes. Match what you see to a row, then jump to the fix.

403 Forbidden + <title>Just a moment...</title>
Cloudflare served a JavaScript challenge. curl_cffi has no JavaScript runtime, so no impersonate target helps. Get a cf_clearance cookie from a real browser or a solver and replay it (step 5).
cf-mitigated: challenge (response header)
Cloudflare's documented marker of a challenge page. Same fix as above. Test for this header in code instead of parsing HTML.
403 "Sorry, you have been blocked" / Error 1020 Access denied
A firewall rule blocked you; there is nothing to solve. No cookie or solver clears it. Change IP or region, or ask the site owner.
200 on my laptop, 403 on the server or in Docker
IP reputation, not the fingerprint. Datacenter IPs are challenged far more often. Use a better proxy and keep it sticky per session.
Works for a while, then 403, 429 or Error 1015
Rate limiting. Slow down, reuse one Session and spread load over several IPs.
Still 403 after I passed my own headers
Your headers contradict the TLS fingerprint. A Firefox UA on a Chrome handshake is an obvious mismatch. Keep the defaults, or set default_headers=False and send a complete, consistent set.
cf_clearance copied from my browser still gets 403
The cookie is bound to the client that earned it. Same User-Agent, same IP, same browser family as the impersonate target, before it expires.
It worked last month and nothing changed
Your fingerprint profile is ageing. Run pip install -U curl_cffi (0.17.0 adds Chrome 151/152, Safari 27 and Firefox 153-155 profiles) or curl-cffi update to fetch newer fingerprints.
Using plain requests or httpx rather than curl_cffi? Start with Cloudflare 403 Forbidden in Python requests →

This error has an entry in our anti-bot error-code reference, next to every other Cloudflare, Turnstile, Kasada, Akamai and reCAPTCHA error.

Why impersonate="chrome" is not enough: fingerprint vs challenge

Cloudflare decides whether to let a request through in layers, and curl_cffi only handles the first one. Its README is explicit about scope: unlike requests or httpx, it can impersonate browsers' TLS/JA3 and HTTP/2 fingerprints. Cloudflare's own docs describe JA3 and JA4 as fingerprints that identify TLS clients by how they start a connection, and site owners can block or challenge specific fingerprints in WAF rules. Plain requests fails here, which is why curl_cffi often turns a 403 into a 200.

The second layer is the challenge page. When a rule decides to challenge you, Cloudflare returns an HTML page that runs JavaScript in the browser; its docs say the visitor must wait until the browser finishes processing that JavaScript, usually in under five seconds, before a cf_clearance cookie is issued. curl_cffi's FAQ answers the obvious question directly: it is a Python binding to a C library, with no browser and no JavaScript runtime, so it cannot run the challenge or change JavaScript fingerprints. A perfect TLS fingerprint only gets you to the challenge faster.

The third layer is everything else. The same FAQ says TLS and HTTP/2 fingerprints are just one of many factors Cloudflare considers, naming IP quality, request rate and JavaScript fingerprints, and adds that higher protection levels may need a better proxy and a real browser. So the right fix depends entirely on which layer produced your 403.

Step 1: find out which layer is blocking you

Before changing anything, look at what Cloudflare actually sent. Cloudflare documents a reliable signal for challenge pages: the cf-mitigated response header is present and set to challenge. A challenge page also carries the "Just a moment..." title. Block pages (1020) and rate limits (1015) look different and need different fixes.

  • cf-mitigated: challenge → JavaScript challenge. Go to step 5; no client-side tuning will fix it.
  • Error 1020 or "you have been blocked" → firewall rule. No cookie clears it; change IP or contact the site owner.
  • Error 1015 or HTTP 429 → rate limit. Slow down before anything else.
  • A 403 with neither marker, or a 200 with odd content → fingerprint, header or IP problem. Steps 2 to 4.
diagnose.py
import curl_cffi

r = curl_cffi.get("https://target-site.com/", impersonate="chrome")
html = r.text

print(r.status_code)                   # 403 on a challenge or a block
print(r.headers.get("cf-mitigated"))   # "challenge" = a JavaScript challenge was served
print(r.headers.get("cf-ray"))         # present on anything Cloudflare answered

if r.headers.get("cf-mitigated") == "challenge" or "<title>Just a moment" in html:
    print("JS challenge: no impersonate target passes this, you need cf_clearance")
elif "1020" in html or "you have been blocked" in html:
    print("Firewall rule: nothing to solve, change IP or ask the site owner")
elif r.status_code == 429 or "1015" in html:
    print("Rate limited: slow down and reuse one Session")
else:
    print("No challenge marker: check target, headers and IP")

Step 2: update curl_cffi and choose the impersonate target on purpose

Fingerprint profiles age. A two-year-old profile looks like a browser almost nobody runs any more. Upgrade first: curl_cffi 0.17.0 (released 2026-10-26) moves to curl-impersonate 2.3.0 and adds Chrome 151/152, Safari 27 and Firefox 153-155 profiles. It needs Python 3.10 or newer, the minimum since v0.14. Since v0.15.1 you can also run curl-cffi update to pull newer fingerprints without upgrading the package, and curl-cffi list shows the targets your install supports.

Then pick the target deliberately:

  • Aliases such as chrome, firefox, safari, chrome_android and safari_ios always map to the newest profile your installed version ships. The docs note that the chrome alias selects the Windows profile.
  • Pinned targets such as chrome146 or safari260_ios keep the fingerprint stable across upgrades.
  • Match the target to the User-Agent you will send. Replaying an iPhone Safari clearance with impersonate="chrome" sends a Chrome handshake under a Safari UA.
  • Do not invent fingerprints. The curl_cffi docs advise against generating random or custom JA3 strings: most sites allowlist known browser fingerprints, so a made-up one stands out more than an old one. Choosing randomly among real, recent targets is fine.
targets.py
import curl_cffi

URL = "https://target-site.com/"

# Newest Chrome profile shipped with your curl_cffi version (Windows profile)
r = curl_cffi.get(URL, impersonate="chrome")

# Pin an exact profile so an upgrade never changes it silently
r = curl_cffi.get(URL, impersonate="chrome146")

# iPhone Safari: use it when the User-Agent you replay comes from an iPhone
r = curl_cffi.get(URL, impersonate="safari_ios")

# CLI helpers:
#   curl-cffi list     -> targets available on this install
#   curl-cffi update   -> fetch newer fingerprints without upgrading (v0.15.1+)

Step 3: stop overriding the headers impersonate sends

By default, setting impersonate also sends that browser's headers in that browser's order. The most common self-inflicted 403 is overwriting them: a User-Agent pasted from an old answer, or a Firefox UA, on top of a current Chrome TLS fingerprint. The handshake says one browser and the headers say another.

If you only need a Referer or an extra cookie, pass just that and let curl_cffi fill in the rest. If you need full control over order or values, the docs say to turn the defaults off and bring your own headers: pass default_headers=False on the request and send a complete set. For lower-level tweaks there is extra_fp, for example {"header_order": "User-Agent,Host,Connection"}.

Use one Session per identity. A Session keeps connections and cookies, so any cookie Cloudflare sets on an earlier response goes back on the next request, the way a browser would behave.

headers.py
import curl_cffi

URL = "https://target-site.com/"
s = curl_cffi.Session(impersonate="chrome")

# Good: keep the browser headers impersonate adds, only add what you need
r = s.get(URL, headers={"Referer": "https://target-site.com/"})

# Bad: a Firefox (or years-old Chrome) UA on top of a current Chrome TLS fingerprint
# r = s.get(URL, headers={"User-Agent": "Mozilla/5.0 ... Firefox/115.0"})

# Full control: switch the defaults off and send one complete, consistent set
r = s.get(
    URL,
    default_headers=False,
    headers={
        "User-Agent": UA,  # must describe the same browser as the impersonate target
        "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
        "Accept-Language": "en-US,en;q=0.9",
    },
)

Step 4: fix the IP, not the fingerprint

If the same script gets 200 from your laptop and 403 from a VPS, the fingerprint did not change; the IP did. Datacenter ranges carry a much worse reputation than home or mobile connections, and the curl_cffi FAQ says plainly that higher protection levels may require a better proxy provider.

  • Pass a proxy per request with proxy="http://user:pass@host:port", or a proxies dict, but not both. HTTP and SOCKS proxies are supported.
  • Keep one IP per session. A cf_clearance earned on one IP and replayed from another is usually challenged again.
  • Rotate IPs between sessions, never in the middle of one.

Step 5: reuse cf_clearance with a matching User-Agent, IP and fingerprint

When the response carries cf-mitigated: challenge, something has to run the challenge and earn a cf_clearance cookie: a real browser, an automation tool or a solver API. curl_cffi then does the part it is good at, fetching pages quickly with that cookie.

The cookie is not a free pass, though. Cloudflare's docs say clearance is securely tied to the specific visitor and device it was issued to, precisely to prevent reuse across machines, and that it stays valid for the Challenge Passage period the site owner configured. In practice three things must match the client that earned it: the exact User-Agent string, the egress IP, and a TLS fingerprint from the same browser family. Miss one and the challenge page comes straight back.

replay_clearance.py
import curl_cffi

UA = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) ..."  # exact UA of the browser that earned the cookie
CF_CLEARANCE = "..."                                    # copied from that same browser
PROXY = "http://user:pass@host:port"                    # the same egress IP it used

s = curl_cffi.Session(impersonate="chrome")             # same browser family as the UA
s.headers["User-Agent"] = UA
s.cookies.set("cf_clearance", CF_CLEARANCE, domain=".target-site.com")

r = s.get("https://target-site.com/", proxy=PROXY)
print(r.status_code, r.headers.get("cf-mitigated"))     # 200 and None when it worked

When to stop tuning curl_cffi

Targets, headers and proxies fix fingerprint and reputation problems. None of them fixes a challenge. If every request returns cf-mitigated: challenge, if the challenge turns interactive, or if you need fresh clearances for many targets and IPs, you need something that executes JavaScript. The realistic options:

  • A real browser (Playwright or similar), which the curl_cffi FAQ itself suggests for higher protection levels. It works, but it is heavy and its stealth patches need upkeep.
  • brimp, a lightweight JavaScript-capable browser from the curl_cffi maintainers, which the README points to for solving JavaScript challenges.
  • A managed solver API that returns cf_clearance plus the matching User-Agent, so curl_cffi stays your HTTP client and nothing heavy runs on your machines.

Example: NSLSolver challenge solve, replayed with curl_cffi

NSLSolver's challenge type runs the JavaScript part for you. POST the target url, the challenge site_key and the proxy you will scrape through to /solve; the response contains cookies (including cf_clearance) and a user_agent to replay through that same proxy. The clearance is issued for an iPhone Safari User-Agent, so leave user_agent out of the request (or send an iPhone Safari UA), replay the one you get back, and use curl_cffi's safari_ios target so the TLS fingerprint and the User-Agent describe the same browser.

Challenge solves take about 3.3 seconds on average and cost $1.00 per 1,000; only successful solves are billed, and you get free credit when you sign up with Google, Gmail or Proton, no card needed. NSLSolver covers Cloudflare Turnstile and Challenge, reCAPTCHA v3, Kasada and Akamai (beta), not reCAPTCHA v2, hCaptcha, image CAPTCHAs or DataDome. Only automate sites you own or are authorised to access.

nslsolver_curl_cffi.py
import curl_cffi

API = "https://api.nslsolver.com/solve"
TARGET = "https://target-site.com/"
PROXY = "http://user:pass@host:port"   # the proxy you will scrape through

data = curl_cffi.post(
    API,
    headers={"X-API-Key": "YOUR_API_KEY"},
    json={
        "type": "challenge",
        "url": TARGET,
        "site_key": "0x4AAAAAAA...",   # the challenge widget id
        "proxy": PROXY,                # required for challenge
        # no user_agent: the clearance is issued for an iPhone Safari browser
    },
    timeout=120,
).json()

# Replay through the SAME proxy, with the returned UA and an iOS Safari fingerprint
s = curl_cffi.Session(impersonate="safari_ios")
s.headers["User-Agent"] = data["user_agent"]
s.cookies.update(data["cookies"])      # includes cf_clearance

r = s.get(TARGET, proxy=PROXY)
print(r.status_code, r.headers.get("cf-mitigated"))

Full /solve API reference

Related guides

Frequently asked questions

Why does curl_cffi still get 403 from Cloudflare with impersonate="chrome"?

Because impersonation only fixes the TLS/JA3 and HTTP/2 fingerprint. If the 403 is a challenge page (the cf-mitigated: challenge header, a "Just a moment..." title), Cloudflare wants JavaScript executed, and curl_cffi has no JavaScript runtime. Without a challenge marker, look at an outdated profile, contradictory headers or a low-reputation IP.

Can curl_cffi solve Cloudflare's JavaScript challenge or Turnstile?

No. The curl_cffi docs state that it is a binding to a C library with no browser or JavaScript runtime, so it cannot run challenge scripts or change JavaScript fingerprints. Get the cf_clearance cookie (or Turnstile token) from a real browser or a solver API, then send it with curl_cffi.

Which impersonate target should I use for Cloudflare?

A recent profile of the same browser your User-Agent claims to be. The chrome alias uses the newest Chrome profile your version ships; pin chrome146 or similar for stability, and use safari_ios to replay an iPhone Safari clearance. Never generate random JA3 strings.

How do I reuse a cf_clearance cookie with curl_cffi?

Set it on a curl_cffi Session together with the exact User-Agent of the browser that earned it, send the requests through the same IP, and use an impersonate target from the same browser family. Clearance is tied to the visitor and device, and expires after the site's Challenge Passage period.

Why does curl_cffi work locally but return 403 on my server?

The fingerprint is the same on both machines, so the difference is the IP. Cloud and VPS ranges have poor reputation and are challenged far more often. Use a better proxy and keep one sticky IP per session.

Does NSLSolver work with curl_cffi?

Yes. Call POST /solve with type challenge, the url, the challenge site_key and your proxy; you get cookies (including cf_clearance) and a user_agent back. Replay them in a curl_cffi Session with impersonate="safari_ios" through the same proxy, because the clearance is issued for an iPhone Safari browser.

Get cf_clearance without running a browser

Keep curl_cffi as your HTTP client and let NSLSolver pass the Cloudflare challenge: one POST returns cf_clearance and the matching User-Agent. Free credit with Google, Gmail or Proton sign-up, no card needed.