cf-turnstile-response invalid: Why Your Turnstile Token Is Rejected and How to Fix It
Originally published on nslsolver.com. cf-turnstile-response is the form field that carries Cloudflare Turnstile's one-time token. "Required" means the field reached the server empty; "invalid" means Cloudflare's siteve
Originally published on nslsolver.com.
cf-turnstile-response is the form field that carries Cloudflare Turnstile's one-time token. "Required" means the field reached the server empty; "invalid" means Cloudflare's siteverify rejected the token.
Fix an empty field by rendering the widget inside the form and sending its token on submit; fix a rejected token by verifying it once, within 300 seconds, with the secret key of the same widget. The table below maps each message to its cause and fix.
Quick answer: what your error message means
Form plugins and frameworks word the same two failures differently: either the token never reached your server, or Cloudflare's siteverify rejected it. Find your exact message below.
| Message | Meaning | Fix |
|---|---|---|
| The cf-turnstile-response field is required. | The token never reached your server. | The hidden cf-turnstile-response input was missing or empty on submit: the widget did not render (CSP, ad blocker, missing api.js), sits outside the <form>, or a JavaScript submit dropped it. Add turnstile.getResponse() to the payload and block submit until the callback fires. |
| Error! Turnstile token required / Turnstile token missing / Please complete the captcha | Same cause: the field was empty. | Usually the visitor submitted before the challenge finished, or a caching or optimization plugin deferred the Turnstile script. Exclude challenges.cloudflare.com from JS deferral and minification. |
| Invalid Turnstile captcha response. / Error! Invalid Turnstile token | siteverify returned success: false. | Read the error-codes array: timeout-or-duplicate (token older than 300 s or verified twice), invalid-input-secret (secret from another widget or not loaded from env), invalid-input-response (malformed or truncated token). |
| Incorrect or missing Turnstile token | The site's Turnstile check failed or never ran. | Site owners: same causes as the two messages above (empty field or rejected token). Visitors seeing it on a shop or login page: reload the page, wait for the check to finish before clicking, and disable VPNs, ad blockers or privacy extensions that block challenges.cloudflare.com. |
| Invalid challenge response | The challenge token was rejected server-side. | Usually an expired or reused token, or a sitekey and secret that come from different Turnstile widgets. Check the error-codes returned by siteverify. |
| Incorrect Turnstile response. Try the verification again. | The token was rejected, usually because it expired. | The form stayed open more than 5 minutes or the request was retried. Call turnstile.reset() in an expired-callback and verify each token exactly once. |
| Turnstile validation failed / Turnstile verify failed | Your server could not get a success from siteverify. | Besides the causes above, check that your server can reach challenges.cloudflare.com (firewall, IPv6, proxy), that you POST form-encoded or JSON with both secret and response, and that hostname and action in the reply match your site. |
| cf-turnstile-response is empty in Selenium, Playwright or requests | Automation never ran a real challenge. | A script that posts the form without a browser cannot produce a token. Get one from a solver API (type turnstile, site_key + url) and send it as cf-turnstile-response within 300 seconds. |
This error has an entry in our anti-bot error-code reference, next to every other Cloudflare, Turnstile, Kasada, Akamai and reCAPTCHA error.
Quick fix
A Turnstile token is the value of the cf-turnstile-response field. Instead of waiting for the widget in a browser, request a valid token with one POST and submit it with your form.
before โ after
# before: drive a browser and wait for the widget
driver.get(URL); time.sleep(10)
token = driver.find_element(By.NAME, "cf-turnstile-response").get_attribute("value")
# after: one POST, no browser
r = requests.post("https://api.nslsolver.com/solve", headers={"X-API-Key": KEY},
json={"type": "turnstile", "site_key": SITE_KEY, "url": URL}).json()
token = r["token"] # send it as cf-turnstile-response
No proxy needed: Turnstile is solved proxyless unless you pass one.
$0.80 per 1,000 solves ยท failed solves are free ยท no browser
Free credit with Google, Gmail or Proton sign-up ยท no card
What the cf-turnstile-response field actually is
When the Turnstile widget runs in the browser, it performs a lightweight challenge and produces a one-time token. That token is written into a hidden form input named cf-turnstile-response (and is also passed to your JavaScript callback). It is the proof that a real browser solved the challenge.
Your backend must take that token and verify it server-side by POSTing it to https://challenges.cloudflare.com/turnstile/v0/siteverify together with your secret key. Cloudflare returns JSON: { "success": true, ... } on success, or { "success": false, "error-codes": [...] } when the token is rejected. A 'cf-turnstile-response invalid' problem is really a non-success siteverify response, and the error-codes array tells you exactly why.
"The cf-turnstile-response field is required": the token never reached your server
This message is different from an invalid token: it means the request arrived with no cf-turnstile-response value at all, so your validation layer (Laravel's required rule, a Django or Express form validator, a WordPress plugin) rejected it before siteverify was even called. Nothing is wrong with Cloudflare โ the browser simply did not send the field.
The widget writes the token into a hidden input named cf-turnstile-response inside its container. If that input is missing or empty when the form is submitted, you get this error. Work through these causes in order:
- The widget never rendered: the api.js script is blocked (a Content-Security-Policy without https://challenges.cloudflare.com in script-src and frame-src, an ad blocker, or the script tag missing on that page). Open DevTools and check that the iframe exists.
- The widget is outside the
<form>: the hidden input is only submitted if the Turnstile container sits inside the form element you post. Move the div.cf-turnstile inside the form. - The form is submitted by JavaScript: a fetch/axios call that builds JSON by hand, or new FormData() on a different element, silently drops the hidden input. Read the token with turnstile.getResponse() and add it to the payload explicitly.
- The user submitted before the challenge finished: disable the submit button until the callback fires, then enable it.
- A custom field name: if you set data-response-field-name (or response-field: false) on the widget, the backend must read that name instead.
- Single-page apps: after a client-side route change the widget is not re-rendered. Call turnstile.render() on mount and turnstile.remove() on unmount.
- Automation with no browser: a scraper or script that POSTs the form never runs the widget, so the field is empty. You need a real token โ see the NSLSolver section below.
Root cause #1: the token is expired or already used (timeout-or-duplicate)
This is by far the most frequent reason a turnstile token is invalid. Turnstile tokens are single-use and short-lived: each token is valid for about 300 seconds (5 minutes) and can be verified exactly once. Submit it twice, or submit it after the window closes, and siteverify replies with error-codes: ["timeout-or-duplicate"].
It happens more than you'd expect in the real world: a user opens a form, gets distracted, attaches a large file, or submits over a slow network, and the token expires in flight. Or your code retries a failed request and accidentally re-verifies the same token. Or a double-clicked submit button fires two requests.
- Refresh the widget after it expires using the JavaScript callback turnstile.reset() (or render with a fresh widget) so the user always submits a current token.
- Verify each token exactly once. Never call /siteverify twice with the same cf-turnstile-response.
- Disable the submit button after the first click to prevent duplicate POSTs.
- If a form can sit open a long time, set an expired-callback that re-runs the challenge before submission.
Root cause #2: sitekey and secret mismatch (invalid-input-secret)
Your frontend renders the widget with a public sitekey; your backend verifies with a private secret key. These two must belong to the same Turnstile widget in the same Cloudflare account. If you mix a sitekey from one widget with the secret of another, or you swapped staging and production keys, every verification fails. The classic siteverify error code here is invalid-input-secret (and missing-input-secret when the secret is empty).
Fix it by opening the Cloudflare dashboard, finding the exact widget, and copying both the sitekey and the secret from that same widget. Store the secret in an environment variable and confirm it is actually loaded at runtime (a missing env var is a surprisingly common culprit). Make sure you are sending the secret as the secret form field, not the sitekey.
Root cause #3: hostname, action, or cData mismatch
A Turnstile widget is bound to the domains you configured for it. If the page that rendered the widget is on a hostname that the widget does not allow, the token will be rejected. The siteverify response includes a hostname field, plus action and cdata fields, that you can and should compare against what you expect.
Three mismatches to check. First, hostname: ensure the domain serving the widget (including subdomains and localhost during development) is on the widget's allowed list, and compare the returned hostname to your own domain. Second, action: if you set a data-action on the widget, verify the action returned by siteverify matches; treat a mismatch as a failure. Third, cData: if you pass custom data via data-cdata, validate the returned cdata. These checks also harden you against token reuse across endpoints. On the client, a wrong sitekey or an unauthorized domain shows up as a 110xxx error (110100, 110110, 110200), not as 600010.
Root cause #4: dummy testing keys, idempotency, and clock skew
A few subtler causes catch experienced developers off guard.
Testing sitekeys in production: Cloudflare's dummy keys (for example the always-passes sitekey 1x00000000000000000000AA) generate a dummy token. A real production secret key will reject that dummy token, and vice versa, a test secret rejects real tokens. If you left a testing key in your build, swap it for your real widget's keys.
idempotency_key reuse: siteverify accepts an optional idempotency_key so you can safely retry verifying the same token and get a cached result. But if you reuse the same idempotency_key for a different token, you get back the cached (old) result, which looks like a wrong or invalid response. Use a fresh idempotency_key per token, or omit it.
Clock skew: token expiry is time-based, so a server clock that drifts can make fresh tokens look expired (or stretch the window incorrectly). Keep your server synced with NTP.
A quick triage checklist
Before changing code, read the error-codes array from your siteverify response. It usually names the exact problem:
- timeout-or-duplicate -> token expired (over ~300s) or verified more than once. Get a fresh token; verify once.
- invalid-input-response -> the cf-turnstile-response is malformed, empty, or expired in transit. Confirm the field is actually being sent.
- invalid-input-secret / missing-input-secret -> wrong or absent secret. Re-copy the secret for the matching widget.
- Client shows 110xxx -> configuration issue (invalid sitekey, domain not allowed). Client shows 300xxx or 600xxx (such as 600010) -> the challenge itself failed because Cloudflare saw bot-like signals: retry, update the browser, disable extensions, try another network. See the full Turnstile error-code list.
When you need a valid token programmatically: NSLSolver
Everything above fixes a legitimate, human-facing integration. But if you are automating, running a scraper, a bot, an integration test against a third-party site, or load tooling, there is no human to solve the widget, and you cannot mint your own valid cf-turnstile-response. You need a service that drives a real challenge and returns a fresh, single-use token you can submit.
That is what NSLSolver does. You POST the target's sitekey and URL to /solve, and it returns a valid Turnstile token you use as the cf-turnstile-response value, just as a browser would. Tokens come back in roughly 250ms on average with a 99.9% success rate, and failed solves are not charged. Turnstile solving is $0.80 per 1,000 solves, pay-as-you-go, and sign-ups with Google, Gmail or Proton get $0.10 of free credit (about 125 Turnstile solves), no card and no crypto required to start.
Because every token NSLSolver returns is fresh, you sidestep the single-use and expiry problems entirely, as long as you submit it promptly (within the ~300s window) and exactly once.
Here is a complete Python example that solves the Turnstile challenge and then submits the token to the target form:
solve_turnstile.py
import requests
NSL_API_KEY = "nsl_YOUR_API_KEY"
TARGET_URL = "https://target-site.com"
SITE_KEY = "0x4AAAAAAA..." # the data-sitekey on the target page
# 1) Ask NSLSolver for a fresh, valid Turnstile token
resp = requests.post(
"https://api.nslsolver.com/solve",
headers={"X-API-Key": NSL_API_KEY},
json={
"type": "turnstile",
"site_key": SITE_KEY,
"url": TARGET_URL,
},
timeout=120,
)
resp.raise_for_status()
token = resp.json()["token"] # e.g. "0.AAAA..."
# 2) Submit the token as the cf-turnstile-response value
# Do this promptly (within ~300s) and only once per token.
submit = requests.post(
f"{TARGET_URL}/login",
data={
"username": "[email protected]",
"password": "secret",
"cf-turnstile-response": token,
},
timeout=30,
)
print(submit.status_code, submit.text[:200])
Skip the workarounds
Solve Cloudflare Turnstile with NSLSolver
One REST call returns a fresh token (or cookies). Pay only for successful solves, with no browser to babysit.
Start free View the Cloudflare Turnstile solver
Free credit with Google, Gmail or Proton ยท no credit card ยท no crypto to start ยท See pricing
See also: the Cloudflare Turnstile solver API for the full integration and pricing, or โ if you are hitting a hard 403 rather than a rejected token โ Cloudflare 403 in Python. Seeing a numeric widget error such as 110200, 200100 or 600010 instead? Check the Turnstile error code reference.
Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes โ full credit and traffic to the original publisher.