Stripe says No such checkout.session when you retrieve a session
No such checkout.sessionShort answer
A resource_missing error means the ID is not visible to the key you used. The usual reasons: the session was created in test mode and you retrieve it with a live key (or the other way round), it lives on a connected account and the Stripe-Account header is missing, or the string you pass is another object's ID or has been cut.
Fix it fast
1Find out which cause you have
Retrieve the session with the exact ID and key from your app, from a terminal. Compare the key prefix (sk_test_ or sk_live_) with the ID prefix (cs_test_ or cs_live_).
curl https://api.stripe.com/v1/checkout/sessions/cs_test_REPLACE_ME -u "$STRIPE_SECRET_KEY:"2Match what you see, then jump to its fix
- 1
The session ID starts with cs_test_ but the key starts with sk_live_ (or cs_live_ with sk_test_).Test and live mode are mixedFix - 2
The same ID is visible in the Dashboard of the connected account, but not for your platform key.The session belongs to a connected accountFix - 3
The ID starts with something other than cs_, such as pi_ or evt_, or it has a trailing space, quote or newline.The ID is not a Checkout Session ID, or it is damagedFix
- 1
What does the error look like?
No such checkout.sessionresource_missing
Cause 1 of 3
Test and live mode are mixed
1Check
Each mode has its own keys and objects. An object from one mode is not accessible from the other, and Stripe documents the livemode_mismatch error code for this.
echo "$STRIPE_SECRET_KEY" | cut -c1-82Fix
Use the key of the mode that created the session on the server that retrieves it. Check which key your deployed environment really has: a test key left in the live environment, or the reverse, is the common slip.
# .env of the server that retrieves the session
STRIPE_SECRET_KEY=sk_test_... # same mode as the cs_test_ session3Verify
Run the first-step command again with the corrected key; it returns the session.
curl https://api.stripe.com/v1/checkout/sessions/cs_test_REPLACE_ME -u "$STRIPE_SECRET_KEY:" | head -5Confirmed by docs.stripe.com
Cause 2 of 3
The session belongs to a connected account
1Check
With Stripe Connect, server calls for a connected account carry that account's ID (acct_...) in the Stripe-Account header. Without it the request is made on your own account, where the session does not exist.
grep -rn "stripe_account\|Stripe-Account" src/ app/2Fix
Send the connected account ID with the retrieve request, the same way you sent it when you created the session.
curl https://api.stripe.com/v1/checkout/sessions/cs_test_REPLACE_ME \
-u "$STRIPE_SECRET_KEY:" \
-H "Stripe-Account: acct_REPLACE_ME"3Verify
The response now contains the session.
curl -s https://api.stripe.com/v1/checkout/sessions/cs_test_REPLACE_ME -u "$STRIPE_SECRET_KEY:" -H "Stripe-Account: acct_REPLACE_ME" | head -3Confirmed by docs.stripe.com
Cause 3 of 3
The ID is not a Checkout Session ID, or it is damaged
1Check
Stripe describes resource_missing as an ID that is not valid: the resource does not exist, or the ID of a different resource was given. A copy that is cut or has an extra character fails the same way. Log the value and its length.
var_dump($sessionId, strlen($sessionId));2Fix
Pass the session id (cs_...) from the object you created, or from session.id in the event, and trim it. Never use the PaymentIntent id here.
$sessionId = trim($_GET['session_id']);3Verify
Retrieve it from a terminal with the same value.
curl https://api.stripe.com/v1/checkout/sessions/$SESSION_ID -u "$STRIPE_SECRET_KEY:"Confirmed by docs.stripe.com
How do I stop it coming back?
- Keep test and live keys in separate environment files, and print the key prefix in your startup log (never the whole key).
- Store the session id you created next to the order, and read it back from there instead of from the URL when you can.
- Do the same for connected accounts: save the acct_ id with the order.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
- TaxiDexMy own multi-tenant taxi dispatch SaaS: API, dispatcher portal, driver and passenger apps, and the servers underneath.
- Spotless LaundryAn on-demand laundry app: Flutter on a Laravel back end, with Firebase for live updates.
- EZ EstimaterConstruction quoting and job tracking for contractors, on a Laravel and Firebase stack.
Related fixes
Payments
Metadata you set on a Stripe Checkout Session is empty when you read it
event.data.object.metadata.order_id is None in the webhook handler
Stripe does not copy metadata between objects on its own.
3 causes, each with a fixPayments
firebase deploy fails because the Stripe client has no API key
Neither apiKey nor config.authenticator provided
The Stripe client is built from a key that is empty at that moment.
3 causes, each with a fixPayments
Stripe Elements shows console warnings or errors in a Next.js checkout
Could not find Elements context; You need to wrap the part of your app that calls useElements() in an <Elements> provider.
Most React Stripe.js warnings come from four mistakes: calling loadStripe inside a component, using useStripe or useElements outside the Elements provider, using the objects before they have loaded, and a Content Security Policy that blocks js.stripe.com.
4 causes, each with a fixPayments
Stripe says there is no such token when your server uses it
livemode_mismatch
Stripe answers with a missing-resource error when the ID you send does not exist for the key you use.
3 causes, each with a fixPayments
A payment method is missing from the Stripe Payment Element, or the call to exclude it fails
Excluding apple_pay, google_pay or link with excluded_payment_method_types returns an error
With automatic payment methods, Stripe decides which methods the Payment Element shows.
5 causes, each with a fixPayments
A Stripe webhook to a Vercel function fails with a 308 redirect
HTTP/2 308
Stripe treats every redirect from a webhook URL as a failure and does not follow it.
3 causes, each with a fix