🎉 Premium Proxies · 24-Hour Free TrialClaim Now
Guides

Turnstile Token Missing, Rejected or Expired: Fixes

Fix Turnstile token errors on your own forms: missing-input-response, invalid-input-response, timeout-or-duplicate, the 300-second rule and test keys.

S SparkProxy 3 12 min read
Share
Turnstile Token Missing, Rejected or Expired: Fixes

A Turnstile token is the short-lived string Cloudflare's Turnstile widget puts in your form, by default in a hidden field named cf-turnstile-response. Your server must send it to Cloudflare's Siteverify API to confirm a real visitor completed the challenge. When that check fails, users see "Turnstile token required", "token missing", "rejected" or "expired", and legitimate sign-ups or logins break. This guide is for developers running Turnstile on their own sites. It maps each symptom to Cloudflare's documented error codes, explains the 300-second and single-use rules that cause most failures, and shows server, client and test code that fixes them.

The Token Lifecycle in 30 Seconds

Cloudflare's server-side validation docs set out the rules plainly:

  • "You must call the Siteverify API to complete your Turnstile implementation. The client-side widget alone does not protect your forms."
  • "Tokens can be forged. An attacker can submit any string to your form endpoint without completing a challenge."
  • "Each token is valid for 300 seconds (5 minutes) after generation."
  • "Tokens are intended for single use." A replay is rejected with timeout-or-duplicate.
  • Maximum token length: 2,048 characters.

The flow:

  1. The widget runs in the visitor's browser and produces a token.
  2. The form submission carries the token.
  3. Your server POSTs it with your secret key to https://challenges.cloudflare.com/turnstile/v0/siteverify.
  4. Cloudflare returns success plus hostname, action, cdata and challenge_ts, or a list of error-codes.
  5. You accept or reject the original request.

Nearly every "token" error is one of those steps happening too late, twice, or not at all.

Symptom to Cause Map

Siteverify's documented error codes, with the user-facing symptom each usually produces:

Siteverify error codeCloudflare's descriptionWhat users or logs showMost common cause
`missing-input-response`Response parameter was not provided"Turnstile token required" or "token missing"Token field not posted, wrong field name, AJAX submit before the widget finished
`invalid-input-response`Token is invalid, malformed, or expired"Token rejected" or "verification failed"Truncated or altered token, a test token sent to a production secret
`timeout-or-duplicate`Token has expired or has already been validated"Token expired" or "please try again"Form submitted after 5 minutes, double submit, server retried validation
`missing-input-secret`Secret parameter not providedEvery submission failsSecret env var missing in production
`invalid-input-secret`Secret key is invalid or expiredEvery submission failsWrong secret, rotated key, test secret in production
`bad-request`Request is malformedEvery submission failsWrong content type or parameters
`internal-error`Internal error occurredIntermittent failuresRetry the validation (safely, with an idempotency key)

If every request fails, look at the secret and request format first. If some fail, it's almost always timing, field names or double submission.

Free trial

Scraping at scale? Skip the blocks.

Fast, unblockable datacentre proxies with unlimited bandwidth.

Token Missing: missing-input-response

Siteverify never received a token. Check these in order:

  1. Field name. The widget creates a hidden input called cf-turnstile-response by default. If you set response-field-name (for example turnstile-token), your backend must read that name. If you set response-field="false", no input is created and you must add the token to the request yourself from the success callback.
  2. AJAX or SPA submits. JavaScript that builds its own FormData or JSON body often skips the hidden input. Read the token from the widget callback or turnstile.getResponse(widgetId) and send it explicitly.
  3. Submitting before the widget finishes. With execution: 'execute' (manual execution) or a slow network, the token doesn't exist yet when the user clicks. Disable the submit button until the success callback fires.
  4. The widget never loaded. Ad blockers, a CSP that blocks challenges.cloudflare.com, or a script error mean no token is ever produced. Client error 200500 ("Iframe load error") points here.
  5. Server-side parsing. Frameworks that only parse JSON won't see a URL-encoded form field, and the reverse is also true.

A safe client pattern holds the button until a token exists and resets after expiry:

<form id="signup" method="post" action="/signup">
  <input name="email" type="email" required>
  
<button id="submit" type="submit" disabled>Create account</button> </form> <script> function onTurnstileOk() { document.getElementById('submit').disabled = false; } function onTurnstileExpired() { document.getElementById('submit').disabled = true; // token no longer valid turnstile.reset(); // ask for a fresh one } function onTurnstileError(code) { document.getElementById('submit').disabled = true; console.warn('Turnstile error', code); // see the widget code table } </script>

Token Rejected: invalid-input-response

Cloudflare received something, but it isn't a valid token. The usual causes:

  • Mangled tokens. Trimming, HTML-escaping, URL-decoding twice, or storing the token in a column shorter than 2,048 characters can all corrupt it. Pass the string through untouched.
  • Mixed test and production keys. Cloudflare's test sitekeys produce the dummy token XXXX.DUMMY.TOKEN.XXXX. Its docs say test secret keys "only accept the dummy token, reject real tokens". The reverse applies too: a production secret rejects the dummy token. A staging build pointing at a production secret, or the other way round, fails every time.
  • Forged or scripted submissions. Bots posting arbitrary strings get exactly this error. That's the system working. Log the source and move on.

Token Expired or Reused: timeout-or-duplicate

This is the most common error on real sites, and it has two causes.

Expired. "The validation token issued by Turnstile is valid for five minutes. If a user submits the form after this period, the token is considered expired." Long forms such as checkout, KYC or multi-step sign-ups often exceed five minutes. The fix is client-side: the widget's refresh-expired option defaults to auto, re-running the challenge when a token expires. If you set it to manual or never, your code must call turnstile.reset() from expired-callback and get a fresh token before submit. A related trap is generating the token at page load for a form the user completes ten minutes later. Use execution: 'execute' and trigger the challenge when the user starts the final step.

Duplicate. A token is meant to be redeemed once. Double submission happens when:

  • the user double-clicks submit, or the browser resubmits after a back-navigation;
  • your frontend retries a failed request with the same token;
  • your server retries Siteverify after a network timeout, and the first call actually succeeded.

Cloudflare's docs add an important nuance: reuse detection is "eventually consistent". The service-level objective is to reject "at least 99% of repeat validation requests received five seconds or more after the first successful validation", and "Multiple validations submitted close together may succeed before redemption state propagates". So don't rely on Turnstile alone to stop a fast double submit. Make the protected action idempotent too.

For safe server retries, Siteverify accepts an idempotency_key, a UUID you generate. Cloudflare excludes "intentional retries using the same idempotency_key" from duplicate rejection. Generate one key per form submission and reuse it only for retries of that same validation.

Secret, Hostname and Action Mismatches

A token can validate as success: true and still be wrong for this request. Cloudflare's examples check the returned hostname and action against what you expect, and reject with hostname_mismatch or action_mismatch if they differ.

  • Hostname. The widget only works on domains listed in Hostname Management. Client error 110200 means "Domain not authorized". Even when validation passes, compare hostname to your production host so a token minted on a staging domain can't be replayed against production.
  • Action. Set data-action="login", "signup" and so on, per form, and check it server-side. Otherwise a token from your low-risk newsletter form works on your login endpoint.
  • cdata. Attach a session or form ID and compare it on validation to bind the token to the session that requested it.
  • Secrets. missing-input-secret and invalid-input-secret are configuration errors: an unset environment variable, a rotated key or a test secret in production. Cloudflare documents a secret-rotation flow, and stale secrets in one deployment cause every validation there to fail.

Widget Error Codes on the Client

When the widget itself fails, no token is produced and the server later reports a missing token. Cloudflare's client-side error codes:

CodeMeaningRetry?Fix
`110100` / `110110` / `400020`Invalid or unknown sitekeyNoCheck the sitekey in the dashboard
`110200`Domain not authorizedNoAdd the domain in Hostname Management
`110600`Challenge timed outYesVisitor's clock may be wrong, or the challenge took too long
`110620`Interaction timed outYesReset with `turnstile.reset()`
`200100`Clock or cache problemNoVisitor clock wrong, or an intermediary cached the challenge
`200500`Iframe load errorYes`challenges.cloudflare.com` blocked by CSP, an extension or the network
`300*`, `600*`Generic challenge failureYesBot behaviour detected. Real users should try another browser or network
`400021`Sitekey domain mismatchNoSitekey region doesn't match the script tag
`400070`Sitekey disabledNoRe-enable it in the dashboard

Cloudflare also notes that a 401 in the browser console during a check is usually harmless, because the widget is requesting a Private Access Token that the device doesn't support. Its troubleshooting list for real users is practical: update the browser, disable extensions, enable JavaScript, try private mode, and avoid VPNs or proxies that interfere.

Test Without Real Challenges

Don't point automated tests at real Turnstile challenges. Cloudflare provides dummy keys "to test your Turnstile implementation without triggering real challenges that would interfere with automated testing suites":

SitekeyBehaviour
`1x00000000000000000000AA`Always passes (visible)
`2x00000000000000000000AB`Always fails (visible)
`1x00000000000000000000BB`Always passes (invisible)
`2x00000000000000000000BB`Always fails (invisible)
`3x00000000000000000000FF`Forces an interactive challenge
Secret keyBehaviour
`1x0000000000000000000000000000000AA`Always passes validation
`2x0000000000000000000000000000000AA`Always fails validation
`3x0000000000000000000000000000000AA`Returns a "token already spent" error

The third secret is the useful one for this topic. Use it to test your duplicate-handling path without waiting five minutes or racing two requests. Dummy sitekeys work on any domain, including localhost. Cloudflare recommends production sitekeys don't allow local domains.

Here's an end-to-end test of your own signup form, run against staging configured with the always-pass keys:

from playwright.sync_api import sync_playwright

with sync_playwright() as p:
    browser = p.chromium.launch()
    page = browser.new_page()
    page.goto("https://staging.example.com/signup")        # uses 1x00000000000000000000AA
    page.fill("input[name=email]", "qa@example.com")
    page.wait_for_function(
        "document.querySelector('[name=\"cf-turnstile-response\"]')?.value.length > 0")
    page.click("#submit")
    page.wait_for_url("**/welcome")
    browser.close()

Our guide to web scraping with Playwright and proxies covers running the same tests from different regions when you need geo-specific QA.

A Validation Function That Handles All of It

This server-side helper turns the rules above into code: an untouched token, the visitor IP, an idempotency key for safe retries, and hostname and action checks.

import uuid
import requests

SITEVERIFY = "https://challenges.cloudflare.com/turnstile/v0/siteverify"

def verify_turnstile(token, secret, remote_ip=None, expected_action=None,
                     expected_hostname=None, retries=2):
    if not token:
        return False, ["missing-input-response"]           # don't call Cloudflare at all
    if len(token) > 2048:
        return False, ["invalid-input-response"]
    data = {"secret": secret, "response": token, "idempotency_key": str(uuid.uuid4())}
    if remote_ip:
        data["remoteip"] = remote_ip
    for attempt in range(retries + 1):
        try:
            r = requests.post(SITEVERIFY, data=data, timeout=10)
            result = r.json()
            break
        except (requests.RequestException, ValueError):
            if attempt == retries:
                return False, ["internal-error"]
            # retry with the SAME idempotency_key so it isn't treated as a duplicate
    if not result.get("success"):
        return False, result.get("error-codes", [])
    if expected_action and result.get("action") != expected_action:
        return False, ["action_mismatch"]
    if expected_hostname and result.get("hostname") != expected_hostname:
        return False, ["hostname_mismatch"]
    return True, []

Map the returned codes to user messages. timeout-or-duplicate gets "Your verification expired, please try again" plus a widget reset. missing-input-response gets "Please complete the verification". Configuration errors go to your logs and an alert, not to the user. Turnstile is one layer of Cloudflare's bot defences. Our overview of Cloudflare's anti-bot stack shows where it sits, and the scraper's-eye view of the same widget is in how Cloudflare Turnstile works for scrapers.

Frequently asked questions

FAQ

It means your server received the form without a Turnstile token, so Siteverify would return missing-input-response. Usually the hidden cf-turnstile-response field wasn't posted: a custom field name, an AJAX submit that skipped it, the widget failing to load, or the user submitting before the challenge finished.

Cloudflare documents a validity of 300 seconds (5 minutes) from generation, and each token is intended for a single validation. After five minutes Siteverify returns timeout-or-duplicate, and the widget must produce a new token, automatically with refresh-expired set to auto or through turnstile.reset().

A rejected token returns invalid-input-response, meaning the token is invalid, malformed or expired. Common causes are altering the token string (escaping, trimming, truncating), mixing Cloudflare's test keys with production keys, or a bot submitting a forged value. Pass the token through untouched and check which secret each environment uses.

It means the token expired after its 5-minute window or was already validated once. Typical causes are long forms, double submissions and server-side retries without an idempotency key. Reuse detection is eventually consistent, so make the protected action idempotent as well.

No. Tokens are intended for single use, and a second validation returns timeout-or-duplicate once the first redemption has propagated. For safe server retries of the same validation, send the same idempotency_key UUID with each attempt, which Cloudflare excludes from duplicate rejection.

Use Cloudflare's dummy keys. The sitekey 1x00000000000000000000AA always passes and 2x00000000000000000000AB always fails. The secret 3x0000000000000000000000000000000AA returns a "token already spent" error. Test sitekeys issue the token XXXX.DUMMY.TOKEN.XXXX, and dummy sitekeys work on localhost.

Special Discount · 20% off

Get 20% off your first month

Premium datacentre proxies with unlimited bandwidth. Use the code at checkout.

Save up to 15% more on quarterly, half-yearly and yearly plans

Claim Discount

About the Author

This guide was written by the SparkProxy Technical Team. SparkProxy runs datacenter proxy infrastructure and a managed Scraping API for web scraping, automation and QA, with HTTP/HTTPS and SOCKS5 access through gateway.sparkproxy.io. Every rule, error code and test key here comes from Cloudflare's Turnstile documentation (server-side validation, widget configurations, client-side error codes and testing pages), read on 21 November 2026.

Keep reading

Related articles

Web Bot Auth: Sign Your Agent's HTTP Requests

Web Bot Auth: Sign Your Agent's HTTP Requests

Web Bot Auth explained and implemented: Ed25519 keys, the key directory, RFC 9421 signatures in Python and Node, who verifies them, and the header format trap.

SparkProxy·Guides