← All posts
·8 min read·GuardLayer·how we write

Supabase "captcha protection: request disallowed"

#supabase#auth#captcha#turnstile#hcaptcha#security

captcha protection: request disallowed (...) is Supabase Auth rejecting a sign-up, sign-in or reset because the captcha token was missing, already used, expired, or checked against the wrong secret. The text in brackets says which. Pass a fresh token as options.captchaToken on every Auth call and reset the widget after each attempt. Don't fix it by turning captcha off, and don't assume it protects anything outside Auth: your tables, RPCs and Server Actions are not covered.

All three captcha errors come from one function, verifyCaptcha in internal/api/middleware.go of supabase/auth. Reading it answers most of the questions people post about this error.

What does "captcha protection: request disallowed" mean?

It means Auth asked your captcha provider about the token and the answer was no, or there was no token to ask about. The function produces exactly these messages:

  • captcha protection: request disallowed (no captcha_token found): HTTP 400. The request body had no gotrue_meta_security.captcha_token.
  • captcha protection: request disallowed (<codes>): HTTP 400. Auth sent the token, your secret and the client IP to hCaptcha's or Cloudflare Turnstile's siteverify endpoint, got success: false, and copied the provider's error-codes into the brackets.
  • captcha verification process failed: HTTP 500. The siteverify call itself failed: no response, a body that wasn't JSON, or an unknown provider name. That's a network or configuration problem, not a bad token.

So the useful part is the bracket. Those codes are the provider's, not Supabase's:

In the bracketsProviderWhat happenedFix
no captcha_token foundSupabaseThe call didn't send a tokenPass options: { captchaToken }
invalid-input-responseBothToken malformed or expiredUse the token the widget just produced, and check the site key and secret are a pair
timeout-or-duplicateTurnstileToken older than 300 seconds, or already redeemedReset the widget and use a new token
already-seen-responsehCaptchaToken was already verified onceSame: one token per request
expired-input-responsehCaptchaToken expiredGet a new one
invalid-input-secretBothThe secret in Supabase is wrongPaste the secret key (not the site key) into Auth's captcha settings
sitekey-secret-mismatchhCaptchaSite key and secret are from different accounts or sitesUse a matching pair

Turnstile's server-side validation docs state the two rules behind most of these: a token is valid for 300 seconds, and it is meant for one validation. hCaptcha documents the same single-use rule as already-seen-response.

Why does it fail on the second attempt?

Because the first attempt spent the token. The usual sequence: the user mistypes a password, signInWithPassword returns "Invalid login credentials", the user tries again, and the form re-sends the token it's still holding. Auth forwards it, the provider has already redeemed it, and the second attempt fails with timeout-or-duplicate or already-seen-response even though the password is now right.

The same thing happens when you reuse the sign-up token for the automatic sign-in after it, when a double-click submits the form twice, or when a sign-in that runs inside a useEffect fires twice under React Strict Mode in development. The fix is to treat the token as single-use in your own code:

"use client";
import { useRef, useState } from "react";
import { Turnstile, type TurnstileInstance } from "@marsidev/react-turnstile";
import { createClient } from "@/lib/supabase/client";

export function SignInForm() {
  const supabase = createClient();
  const captcha = useRef<TurnstileInstance>(null);
  const [captchaToken, setCaptchaToken] = useState<string>();

  async function onSubmit(email: string, password: string) {
    const { error } = await supabase.auth.signInWithPassword({
      email,
      password,
      options: { captchaToken },
    });

    // The token is spent whether this succeeded or not.
    captcha.current?.reset();
    setCaptchaToken(undefined);
    if (error) return showError(error.message); // your own error UI
  }

  return (
    <form /* ... */>
      {/* email + password fields */}
      <Turnstile
        ref={captcha}
        siteKey={process.env.NEXT_PUBLIC_TURNSTILE_SITE_KEY!}
        onSuccess={setCaptchaToken}
      />
      <button disabled={!captchaToken}>Sign in</button>
    </form>
  );
}

The site key is public and fine in a NEXT_PUBLIC_ variable. The secret key goes only into Supabase's captcha settings, never into your app.

Which Supabase calls need a captcha token?

Once captcha is on, every Auth route wrapped in verifyCaptcha needs one. In internal/api/api.go that's /signup, /token, /otp, /magiclink, /recover, /resend, /sso, and passkey authentication options. In supabase-js terms: signUp, signInAnonymously, signInWithPassword, signInWithOtp, resetPasswordForEmail, resend and signInWithSSO.

/token has exceptions, listed in isIgnoreCaptchaRoute in the same file: grant_type=refresh_token, pkce and id_token skip the check, while password and web3 don't. So refreshing a session, exchangeCodeForSession and signInWithIdToken keep working without a token. verifyOtp isn't wrapped at all.

There's one more skip: a request whose Authorization header carries admin credentials bypasses captcha entirely. A supabase-js client created with the service role key sends that key as its Authorization header, so its signUp() calls skip the check. The admin endpoints behind supabase.auth.admin.createUser() aren't wrapped in verifyCaptcha in the first place. Either way, an API route that creates users with the service role on behalf of anonymous visitors has quietly removed your captcha. Calling the normal Auth methods from a Server Action doesn't skip anything, though: Auth checks the token whatever the caller is, so pass it through from the form.

What captcha doesn't cover

Supabase captcha guards Auth endpoints. It doesn't sit in front of PostgREST, your RPC functions, Edge Functions or your Next.js routes. A bot that wants to fill your waitlist doesn't need to sign up. It reads your project URL and anon key from your JavaScript bundle and posts straight to /rest/v1/waitlist:

guardlayer scan · supabase/migrations/20261201100000_waitlist.sqlLive engine output
Passed with warnings
92/100 · A
  • Warningsupabase/migrations/20261201100000_waitlist.sql:10

    Overly permissive RLS policy

    Scope the policy to the requesting user, e.g. USING (auth.uid() = user_id). Reserve (true) for genuinely public, read-only data.

That migration is the common setup for a public form, and the comment is the common assumption. For tables created since Supabase's October 30 Data API change, the grant line is what opens the table to the API, and the (true) policy accepts whatever arrives. Captcha never runs, because no Auth endpoint is involved. GuardLayer reports it as supabase/policy-using-true: an insert policy that accepts any row from anon.

If a public form needs bot protection, verify the token yourself on the server and keep the table closed to anon:

// app/waitlist/actions.ts
"use server";
import { createAdminClient } from "@/lib/supabase/admin"; // server-only, service role

export async function joinWaitlist(email: string, token: string) {
  const res = await fetch("https://challenges.cloudflare.com/turnstile/v0/siteverify", {
    method: "POST",
    body: new URLSearchParams({ secret: process.env.TURNSTILE_SECRET_KEY!, response: token }),
  });
  const outcome = await res.json();
  if (!outcome.success) return { error: "Captcha failed" };

  const admin = createAdminClient();
  await admin.from("waitlist").insert({ email: email.trim().toLowerCase() });
  return { ok: true };
}

Then drop the anon policy and revoke insert on public.waitlist from anon;. Captcha raises the cost of each request, but it doesn't cap how many get through, so pair it with rate limiting on the Server Action.

Don't switch captcha off to make the error go away

If the error is blocking users, fix the token handling. Turning captcha off reopens what it was there for: scripted sign-ups, OTP and SMS requests that cost you money per message, and password-reset spam. It matters most with anonymous sign-ins enabled, where every call creates an auth.users row that stays until you delete it. Supabase's own Auth rate limits still apply without captcha, but most of them are counted per IP address, and a botnet has plenty of those.

A quick self-check

  1. Search for every Auth call that needs a token and confirm each passes one: grep -rn "signUp\|signInWithPassword\|signInWithOtp\|signInAnonymously\|resetPasswordForEmail" app components lib.
  2. Confirm each form resets the widget after every attempt, success or failure.
  3. Search for auth.admin. and service-role clients (SUPABASE_SERVICE_ROLE_KEY) in routes that unauthenticated visitors can reach. Each Auth call they make bypasses captcha.
  4. List the tables anon can insert into: select c.relname from pg_class c join pg_namespace n on n.oid = c.relnamespace where n.nspname = 'public' and c.relkind = 'r' and has_table_privilege('anon', c.oid, 'INSERT');. Captcha protects none of them; RLS policies decide which rows get in.

FAQ

Why do I get "no captcha_token found" when the widget shows a checkmark? The widget produced a token but the Auth call didn't include it. supabase-js only sends it when you pass options: { captchaToken } (for resetPasswordForEmail, the second argument's captchaToken). Log the token right before the call to confirm it's set.

What does timeout-or-duplicate mean in Supabase? It's Cloudflare Turnstile's code for a token that's older than 300 seconds or was already redeemed. Get a new token by resetting the widget, and never send the same token twice.

Why does "captcha verification process failed" return a 500? Auth couldn't complete the call to the provider's siteverify endpoint, or couldn't read the reply. A wrong secret doesn't cause it: that comes back as invalid-input-secret in a 400. Check the provider setting matches your keys, then check the provider's status.

Does the service role key skip Supabase captcha? Yes. Auth skips the captcha check when the request carries admin credentials. Keep admin Auth calls behind your own checks, and never put the service role key in the browser.

Does Supabase captcha protect my database from bots? No. It only checks requests to Auth endpoints like sign-up, sign-in, OTP and password reset. Inserts, updates and RPC calls through the Data API go straight past it, so protect them with RLS, grants and server-side checks.

live check · read-only

Check your Supabase Auth settings and tables, free

Connect your Supabase project read-only. GuardLayer checks your Auth settings (leaked passwords, email confirmation, secure email change, token rotation, CAPTCHA, MFA) and your RLS, policies and grants, and says how to fix each problem. It never reads your rows and can't change anything.

Check my Supabase project

Prefer to check code instead? Scan your repo, no signup.

Keep reading