The cf_clearance Cookie, Explained (and How to Reuse It)
What the cf_clearance cookie is, why it is bound to your IP and user-agent, and how to get and reuse it to skip Cloudflare's 5-second challenge.
You solve Cloudflare's "checking your browser" page once, and then every follow-up request gets challenged again. The thing you're missing is a cookie: cf_clearance. Hold onto it correctly and the rest of your session sails through. Handle it wrong and you're stuck in a loop.
cf_clearance is the cookie Cloudflare sets after a browser passes the 5-second interstitial (or a managed challenge). It's proof that this visitor cleared the check, so Cloudflare stops re-challenging. For automation, that cookie is the whole prize: get it once, reuse it, skip the challenge on subsequent requests.
Why you can't just copy the cookie and go
Here's the part that trips people up. cf_clearance isn't portable. Cloudflare binds it to two things: the IP address that earned it and the user-agent of the browser that earned it. Move the cookie to a different IP or send it with a different user-agent, and Cloudflare throws it out and challenges you again.
So reuse has three rules. Same cookie, same IP, same user-agent. Break any one and it stops working. That's why a sticky session proxy matters here: you need the IP that got the clearance to stay yours for the life of the session.
Getting cf_clearance with a solving API
You can drive a real browser to earn the cookie, or call an API that returns it. With Peak, the cloudflare5stask gives you back the cookie, the matching user-agent, and the supporting headers in one response, so you don't have to keep a browser alive.
import requests
sol = requests.post(
"https://api.peak.fo/solve",
headers={"X-API-Key": "pk_your_api_key"},
json={
"task_type": "cloudflare5stask",
"url": "https://target.com/",
"proxy": "http://user:pass@ip:port",
},
timeout=30,
).json()["data"]
# reuse the clearance cookie + the SAME user-agent on your session
session = requests.Session()
session.headers["User-Agent"] = sol["headers"]["user-agent"]
for name, value in sol["cookies"].items():
session.cookies.set(name, value)
# keep using the same proxy (same IP) that earned the clearance
page = session.get("https://target.com/protected",
proxies={"http": "http://user:pass@ip:port",
"https": "http://user:pass@ip:port"})
print(page.status_code)The response carries cf_clearance plus __cf_bm (Cloudflare's bot-management cookie) and the user-agent string that matches them. Set all of it together. The most common mistake is grabbing cf_clearance alone and sending it with your own default user-agent, which doesn't match, so Cloudflare rejects it.
How long does it last?
Clearance cookies are short-lived by design, and Cloudflare tunes the lifetime per site, so don't hard-code an assumption. Treat it as a session token: use it while it works, catch the moment a request gets challenged again, and solve once more to refresh. Because Peak only bills successful solves, a refresh here and there costs a tenth of a cent each and nothing when a solve misses.
Turnstile vs the 5-second challenge
Don't confuse the two. Turnstile is a widget that returns a token you submit with a form; the 5-second challenge is an interstitial that returns a cookie you reuse on requests. Different mechanisms, different handling. If you're dealing with the widget instead, read how to solve Cloudflare Turnstile. The full parameter reference for both is in the Peak docs.
FAQ
What is the cf_clearance cookie?
It's the cookie Cloudflare sets once a browser passes the 5-second or managed challenge. It tells Cloudflare this visitor already cleared the check, so subsequent requests aren't challenged, as long as they come from the same IP with the same user-agent.
Can I reuse cf_clearance across IPs?
No. Cloudflare binds it to the IP and user-agent that earned it. Use a sticky session proxy so the IP stays constant, and always send the matching user-agent.
How do I get cf_clearance automatically?
Run the cloudflare5stask against the protected URL with a sticky proxy; the response returns the cookie and the matching user-agent to reuse. See pricing to start.
Clearing Cloudflare at scale? Grab a key free at peak.fo.