Stripe webhook "signature verification failed": how to fix it
"No signatures found matching the expected signature for payload" means a wrong signing secret or a changed request body. Fixes for Next.js, Express and Edge Functions.
5 min readstripe, webhooks, error fix, payments
Short answer: the Stripe error No signatures found matching the expected signature for payload means your server could not match Stripe's signature to the request it received. In practice there are two causes: you are using the wrong webhook signing secret, or your code changed the request body before checking it. Fix the secret first, then make sure you verify the raw, untouched body.
If your app is built with an AI tool, this is likely the reason customers pay but your app never records it. The webhook arrives, your code rejects it, and Stripe retries for a while and then gives up.
How the check works
Stripe signs every webhook with a secret that starts whsec_. Your server takes three things, the exact raw body, the Stripe-Signature header and the secret, and asks Stripe's library whether they match. Change one byte of the body, or use a different secret, and the answer is no.
Cause 1: the wrong signing secret
This is the most common cause, and Stripe's own troubleshooting guide lists it first. Each webhook endpoint has its own secret. Check these:
- Test versus live. Test mode and live mode have separate endpoints and separate secrets. A live site holding the test secret fails every check.
- Stripe CLI versus dashboard. If you run
stripe listenwhile developing, the CLI prints its own temporary secret. It does not work against an endpoint created in the dashboard, and the reverse. - More than one endpoint. If you created a second endpoint, its secret differs from the first.
- Copy errors. A trailing space or a missing character. Copy it again from the dashboard (Developers, Webhooks, your endpoint, Signing secret).
After changing an environment variable on your host, redeploy or restart so the new value is read.
Cause 2: the body was changed before checking
The signature covers the exact bytes Stripe sent. If a framework parses the JSON and your code then turns it back into text, the bytes differ, and the check fails. You must pass the raw body.
Next.js (App Router)
export async function POST(req: Request) {
const body = await req.text();
const signature = req.headers.get("stripe-signature")!;
const event = stripe.webhooks.constructEvent(
body,
signature,
process.env.STRIPE_WEBHOOK_SECRET!
);
return new Response("ok");
}
Use await req.text(), not await req.json().
Express
The JSON parser must not run on the webhook route. Give that route a raw parser and register it before express.json():
app.post(
"/webhook",
express.raw({ type: "application/json" }),
(req, res) => {
const event = stripe.webhooks.constructEvent(
req.body,
req.headers["stripe-signature"],
process.env.STRIPE_WEBHOOK_SECRET
);
res.sendStatus(200);
}
);
app.use(express.json());
Supabase Edge Functions and other Deno code
Deno uses a different crypto engine, so use the async version of the check and read the body as text:
const body = await req.text();
const event = await stripe.webhooks.constructEventAsync(
body,
req.headers.get("stripe-signature")!,
Deno.env.get("STRIPE_WEBHOOK_SECRET")!,
undefined,
Stripe.createSubtleCryptoProvider()
);
Django and other frameworks
Use the framework's raw body (request.body in plain Django views) and make sure no middleware, proxy or decorator has reformatted it first.
Cause 3: something in front of your server changes the request
A proxy, firewall or hosting setting that rewrites or compresses the body will break the signature. Some hosts also need a setting to leave request bodies alone for a given route. If everything else is right and it still fails, test the endpoint directly, without the proxy.
Cause 4: several sites share one Stripe account
If two websites use the same account and both have webhook endpoints, Stripe sends each event to both. The site that does not own the event may reject it. Give each site its own endpoint and secret, and ignore events that are not meant for it.
Test it
- In the Stripe dashboard, open your endpoint and send a test event.
- Look at the delivery: a
200response means it worked, a400means your check failed. - Locally, run
stripe listen --forward-to localhost:3000/api/webhookand use the secret the CLI prints. - Log the length of the raw body when it arrives. If it is not what Stripe sent, something changed it.
Ask your AI tool
"Our Stripe webhook fails with 'No signatures found matching the expected signature for payload'. Make sure we verify the raw request body (not parsed JSON), use the signing secret for this exact endpoint and mode, and log a clear error if verification fails. Do not remove signature verification."
Never fix this by skipping verification. Without it, anyone who knows your webhook address can send a fake "payment succeeded" message.
FAQ
Where do I find the whsec_ secret?
In the Stripe dashboard under Developers, then Webhooks, open your endpoint and reveal the signing secret.
Why does it work locally and fail in production?
Locally you probably use the CLI secret. Production needs the dashboard endpoint's secret, in live mode.
Is it safe to skip verification while I debug?
Only on a local machine, and put it back immediately.
Why do my orders still not appear after I fix it?
Failed events may have exhausted their retries. Resend them from the dashboard, and make your handler safe to run twice.
When it keeps happening
Payment code is the part of an AI-built app that costs real money when it is wrong. Our audit reads the webhook handler line by line. Send us a link, or see the bigger picture in the customer paid, but your app never heard about it.