"Cloudflare Turnstile Verification Failed": Why It Happens and How to Fix It
Every cause of "Turnstile verification failed", client-side and server-side, mapped to its fix.
"Cloudflare Turnstile verification failed": the short answer
When you see cloudflare turnstile verification failed, the token is almost always expired or reused (single-use, ~300s TTL), the sitekey doesn't match the domain, or your server sent the wrong secret to siteverify. Clock skew, a blocked Turnstile script, ad blockers, and bot detection cause the rest. Each has a specific fix, and most take minutes once you know which one you hit.
There are two places this error shows up, and they're worth separating before you start debugging. The first is client-side: the widget itself renders an error state and never hands you a token. The second is server-side: the widget produced a token, your backend posted it to Cloudflare's siteverify endpoint, and the response came back with success: false. The fix depends on which side failed, so figure that out first.
Why the Turnstile widget fails in the browser
If turnstile failed before you ever get a token, the problem is on the page. Here are the causes that actually show up in production, ordered by how often they bite.
Wrong or mismatched sitekey
The sitekey is public and lives in your widget markup (the data-sitekey attribute or the sitekey option). If you copied a sitekey from a different Cloudflare account, a different widget, or a staging config, Turnstile refuses to render a valid challenge. A classic version of this: using the testing sitekeys (the ones that always pass or always fail) and forgetting to swap them for real keys before deploy. Check that the sitekey on the live page matches the widget you created in the Cloudflare dashboard, character for character.
Hostname and domain mismatch
Every Turnstile widget is scoped to a list of allowed hostnames. If your widget is configured for example.com but you're loading it on app.example.com, a preview URL, localhost, or an IP address, the challenge fails. This is one of the most common reasons cloudflare turnstile not working appears right after a deploy to a new subdomain. Open the widget settings in the dashboard and confirm every hostname you serve from is in the allowed list, including local dev hosts if you test there.
Blocked or failed Turnstile JavaScript
The widget depends on https://challenges.cloudflare.com/turnstile/v0/api.js. If a Content Security Policy blocks that origin, the script 404s behind a strict corporate proxy, or it's loaded async in a way that races your render call, the widget can't initialize. Open the browser console and the network tab. If api.js didn't load, or your CSP is throwing a script-src violation, that's your turnstile error right there. Add challenges.cloudflare.com to your CSP script-src and frame-src.
Ad blockers and privacy extensions
uBlock Origin, Privacy Badger, Brave's shields, and a handful of DNS-level blockers sometimes catch Turnstile in a wider anti-tracking net. The widget either doesn't render or returns an error for that visitor only. You can't fix a user's extension from your side, but you can detect the failure with Turnstile's error-callback and show a message that tells them to disable blocking for your domain, rather than leaving them staring at a dead form.
Clock skew on the client
Turnstile tokens carry timing information. A device with a badly wrong system clock, or a server reading an expired token because its own time drifted, can make a perfectly good token look invalid. On servers this is the more common version. If siteverify keeps rejecting fresh tokens across the board, check that NTP is running and your box isn't minutes off real time.
Why siteverify returns "verification failed" on the server
Once the widget hands you a token, your backend has to validate it. You POST the token plus your secret key to Cloudflare, and you read the JSON that comes back. Skip this step, or do it wrong, and you've effectively got no protection at all even when the widget looks fine. Here's the flow in one real call:
curl -X POST https://challenges.cloudflare.com/turnstile/v0/siteverify \
-d "secret=YOUR_SECRET_KEY" \
-d "response=TOKEN_FROM_WIDGET" \
-d "remoteip=USER_IP"
# Response on success:
# {"success": true, "challenge_ts": "2026-09-08T12:00:00Z",
# "hostname": "example.com", "error-codes": []}
# Response on failure:
# {"success": false, "error-codes": ["timeout-or-duplicate"]}The success field is the only thing that decides whether the user passes. Never trust the presence of a token alone. Read success, and when it's false, read error-codes, which tells you exactly what went wrong.
timeout-or-duplicate: the expired or reused token
This is the single most frequent server-side failure. Turnstile tokens are valid once and expire in roughly 300 seconds. You get timeout-or-duplicate when:
- The user sat on the form past the TTL before submitting, so the token aged out.
- Your code validated the same token twice (a double-submit, a retry, or a page that re-posts on refresh).
- You cached or stored the token and replayed it later.
The fix is to verify server-side promptly and exactly once, then reset the widget to mint a fresh token for the next attempt. If a user's submission fails validation for an unrelated reason, call turnstile.reset() so they aren't handed back a dead token on their second try. For a deeper breakdown of every status string Cloudflare can return, see our guide to Cloudflare Turnstile error codes.
invalid-input-response: malformed or empty token
This means the response you sent wasn't a token Cloudflare recognizes. Usually the token arrived empty because the widget hadn't finished solving when your form submitted, or your frontend read the wrong field name. The Turnstile response field is named cf-turnstile-response; if your handler looks for something else, you'll forward an empty string and get this code. We walk through the empty-token case specifically in why the cf-turnstile-response is empty.
invalid-input-secret and missing-input-secret
Your secret key is wrong, truncated, or absent. This happens when the secret lives in an environment variable that didn't load, you pasted the sitekey into the secret slot by accident, or your staging and production secrets got crossed. The secret is private and must never appear in client code. If every single verification fails with this code, check the env var your server actually reads at runtime, not the one in your .env.example.
bad-request and missing-input-response
The request to siteverify was malformed, or the response parameter never got sent. Confirm you're POSTing form-encoded data (or JSON, if you use that endpoint variant) and that the token field name matches what your framework parses out of the request body.
Automation and bot detection: the other reason tokens fail
Turnstile is a bot-management product, so some "failures" are the system doing its job. If you're running a scraper, a monitoring check, a load test, or an integration test suite, the widget will often refuse to solve, or the token it produces gets rejected downstream because the session looked automated. A headless browser with default fingerprints, a datacenter IP, or a session missing the signals Turnstile expects will trip the challenge.
For legitimate automation (your own account, your own monitoring, testing against your own forms, respecting the target's ToS and robots.txt) the clean path is to get a real, valid token on demand instead of fighting a headless browser's fingerprint. That's what Peak does: you send the page URL and sitekey, and you get back a fresh single-use token you can feed straight into your siteverify flow.
import requests
r = requests.post(
"https://api.peak.fo/solve",
headers={"X-API-Key": "YOUR_PEAK_KEY"},
json={
"task_type": "turnstiletaskproxyless",
"url": "https://example.com/login",
"sitekey": "0x4AAAAAAA...",
},
)
data = r.json()
# {"success": true, "data": {"token": "1.xxxx"}, "cost": 0.0009}
token = data["data"]["token"]
# Submit `token` to your form or straight to siteverify, promptly.A typical solve comes back in about a second, and you pay only for tokens that actually succeed. Because the token is single-use and expires in ~300 seconds, treat it like any other Turnstile token: use it right away, verify once, don't cache it. Pricing runs from $0.90 per 1,000 solves down to roughly $0.35 at volume. If you just want to see a live token get minted and verified before wiring anything up, the Cloudflare Turnstile tester runs a real solve and a real siteverify check in the browser.
A debugging checklist
Run this in order and you'll catch almost every case:
- Open the console. Did
api.jsload? Any CSP violations? That rules the client-side causes in or out fast. - Log the raw siteverify response. Print
successanderror-codesfor every verification. Guessing without this wastes hours. - Check the token's age. If
timeout-or-duplicatekeeps showing, measure the time between token creation and verification. Anything near 300 seconds, or any path that verifies twice, is your culprit. - Diff your keys. Confirm the live sitekey matches the dashboard widget and that the secret your server reads at runtime is the right one.
- Verify the hostname list. Every subdomain and dev host you serve the widget from must be allowed.
- Sync your clocks. Make sure NTP is running on the server doing verification.
- Handle the failure path. Wire up
error-callbackand callreset()after a failed submit so users get a fresh token instead of a recycled dead one.
Common mistakes, mapped to their fix
| Symptom | Likely cause | Fix |
|---|---|---|
| Widget never renders | CSP blocks api.js, or wrong sitekey | Allow challenges.cloudflare.com; verify sitekey |
| Fails for some users only | Ad blocker or privacy extension | Detect with error-callback; prompt to allowlist your domain |
timeout-or-duplicate | Expired or reused token | Verify once, promptly; reset widget after failures |
invalid-input-response | Empty or malformed token | Read cf-turnstile-response; wait for solve before submit |
invalid-input-secret | Wrong or missing secret | Check the runtime env var; never use the sitekey here |
| All tokens rejected | Server clock skew | Run NTP; confirm system time |
| Fails under automation | Bot detection | Get a real token via a solver for legitimate use cases |
Get a token that passes
Most "verification failed" errors come down to a token that's stale, reused, scoped to the wrong domain, or checked against the wrong secret. Fix the one that matches your error-codes output and you're done. And if your blocker is automation on your own endpoints, skip the headless-browser fingerprint fight: send a URL and sitekey to Peak, get a fresh single-use token in about a second, and verify it server-side like any other. Try a live solve on the Turnstile tester and wire it into your flow from there.