
Stripe "No such price" means the secret key your server used cannot see the price_... ID you sent. You get it as a 400 error with the code resource_missing, usually when you create a Checkout Session or a subscription. Most of the time the price is real. It was created in live mode and you called with a test key, or the other way round, or it belongs to a different Stripe account, a different sandbox or a connected account. Below I go through each cause, how to tell them apart from the message alone, and the tested Node/TypeScript code I use so price IDs never get hard-coded again.
Quick answer
Read the end of the error message. "A similar object exists in live mode, but a test mode key was used" means a live price ID with a sk_test_ key. "A similar object exists in test mode, but a live mode key was used" means a test price ID with a sk_live_ key. No extra sentence means the price is not in that account at all: check the connected account (stripeAccount option), the account or sandbox you copied the ID from, and the value itself. Then stop hard-coding IDs and look prices up by lookup_key.
What this means for your app or business
- What customers see. The Buy or Subscribe button does nothing or shows a generic error. No payment is taken, so you lose the sale rather than charging anyone wrongly.
- When it happens. Almost always on launch day, right after switching to live keys, or after someone sets up a new Stripe sandbox, account or deployment.
- How long the fix takes. If it is a key or ID mix-up, minutes: correct an environment variable and redeploy. Moving price IDs into lookup keys and adding a startup check is usually a few hours.
- When to get help. If you use Stripe Connect (a marketplace or platform), or checkout broke and you cannot tell which keys are deployed where, get a developer to check it before more sales fail.
What does the "No such price" error look like?
The JSON body from Stripe looks like this (the param changes with the call):
{
"error": {
"code": "resource_missing",
"doc_url": "https://stripe.com/docs/error-codes/resource-missing",
"message": "No such price: 'price_1Abc...'; a similar object exists in live mode, but a test mode key was used to make this request.",
"param": "line_items[0][price]",
"type": "invalid_request_error"
}
}This exact sentence appears in a Stack Overflow question from someone testing locally with a live price ID. The reverse, "a similar object exists in test mode, but a live mode key was used to make this request", is what you see after going live with test IDs still in the code. A Stripe engineer described the extra sentence in stripe-node issue #149 as "our API trying to be helpful": the object exists, you are just asking for it with the wrong key.
Stripe's error codes page describes resource_missing as "The ID provided isn't valid. Either the resource doesn't exist, or an ID for a different resource has been provided." In stripe-node it arrives as a StripeInvalidRequestError with code, param, statusCode 400 and requestId.
Why does Stripe say no such price when the price exists?
Stripe's API keys guide says each mode has its own keys and "objects in one mode aren't accessible to the other". A price ID is only valid for keys of the same account and the same mode. These are the causes I see, in order of how often they come up:
| Cause | What the message says | Fix |
|---|---|---|
| Live price ID, test key | "...exists in live mode, but a test mode key was used" | Use the sandbox price ID, or look it up by lookup_key |
| Test price ID, live key | "...exists in test mode, but a live mode key was used" | Copy the product to live mode and use the new live price ID |
| Price lives on a connected account | No extra sentence | Pass stripeAccount (the Stripe-Account header) on every call |
| ID from another Stripe account or sandbox | No extra sentence | Copy the ID from the account and sandbox your key belongs to |
Typo, prod_ ID, whitespace, unset env var | No extra sentence | Fix the value; a prod_ ID is not a price ID |
| Price archived | "The price specified is inactive. This field only accepts active prices." | Unarchive it or move the lookup_key to an active price |

Test mode, sandboxes and live mode
Stripe now calls its test environments sandboxes. The sandboxes docs recommend general sandboxes for new integrations, with separate ones for local development and CI, while older accounts still have the legacy test mode sandbox. All of them use sk_test_ and pk_test_ keys, so the prefix alone does not tell you which sandbox a key belongs to. Each sandbox has its own objects, and Stripe's testing guide warns that a new sandbox means new test object IDs. A price copied from sandbox A will not resolve with sandbox B's key.
Going live has the same trap. The Copy to live mode button on a product page copies the product and its prices, but the copies get new IDs (manage prices docs). The live price ID is never the test one.
Environment variable mix-ups
This is where most of my client fixes end up. A few patterns:
- Vercel production has
sk_live_but a preview or local.envstill has a live price ID, or the reverse. - The publishable key and the secret key come from different modes, or from different Stripe accounts after an agency handover.
- The value was changed but never deployed. Vercel applies environment variable changes only to new deployments, and Next.js inlines `NEXT_PUBLIC_` variables into the browser bundle at build time, so a price ID read in client code needs a rebuild.
- Firebase Functions secrets set in one Firebase project while the app calls another. I check this on every Firebase Stripe extension migration.
Stripe Connect: the price is on a connected account
If your platform creates prices on connected accounts (direct charges), every request about those prices must name the account. Stripe's Connect guide says to send the connected account ID in the Stripe-Account header; in stripe-node that is the stripeAccount request option. A common failure, as in this Stack Overflow question, is reading the product on the platform account and then creating the Checkout Session on the connected account. With destination charges it is the other way round: the charge happens on the platform, so the price must exist on the platform. If the account ID itself is wrong or not connected, you get account_invalid with HTTP 403 instead.
How do I fix "No such price" in Node.js?
Step 1: check the price from the command line
With the Stripe CLI, use the same key your server uses:
# Does this key see the price? Shows livemode and active.
stripe prices retrieve price_1Abc --api-key "$STRIPE_SECRET_KEY"
# On a connected account
stripe prices retrieve price_1Abc --api-key "$STRIPE_SECRET_KEY" --stripe-account acct_123
# Find the active price for a lookup key in this key's account and mode
stripe prices list --lookup-keys pro_monthly --active=true --api-key "$STRIPE_SECRET_KEY"If retrieve works on the CLI but fails in your app, the app is not using the key you think it is.
Step 2: refuse to start with mismatched keys
I add this check at server startup. It throws if the secret key (sk_ or restricted rk_) is not the mode the environment expects, if the publishable key's mode differs, or if the value has a stray newline from a copy and paste.
// Fail fast at startup if Stripe keys are from the wrong mode or don't match each other.
export type StripeMode = 'test' | 'live';
export function keyMode(key: string | undefined, kinds: string[]): StripeMode {
const k = (key ?? '').trim();
for (const kind of kinds) {
if (k.startsWith(`${kind}_test_`)) return 'test';
if (k.startsWith(`${kind}_live_`)) return 'live';
}
throw new Error(`Stripe key is missing or is not a ${kinds.join('/')} key (got "${k.slice(0, 8)}...")`);
}
export function assertStripeKeys(opts: {
secretKey: string | undefined; // STRIPE_SECRET_KEY (sk_ or rk_)
publishableKey?: string | undefined; // NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY (pk_)
expectedMode: StripeMode; // 'live' in production, 'test' everywhere else
}): StripeMode {
if (opts.secretKey !== opts.secretKey?.trim()) {
throw new Error('STRIPE_SECRET_KEY has leading or trailing whitespace');
}
const secretMode = keyMode(opts.secretKey, ['sk', 'rk']);
if (secretMode !== opts.expectedMode) {
throw new Error(`STRIPE_SECRET_KEY is a ${secretMode} key, but this environment expects ${opts.expectedMode}`);
}
if (opts.publishableKey !== undefined) {
const pubMode = keyMode(opts.publishableKey, ['pk']);
if (pubMode !== secretMode) {
throw new Error(`Publishable key is ${pubMode} but secret key is ${secretMode}`);
}
}
return secretMode;
}Call it once where you create the Stripe client, for example with expectedMode: process.env.VERCEL_ENV === 'production' ? 'live' : 'test'. It cannot tell two sandboxes or two accounts apart, because their keys share prefixes. The lookup key approach in the next step covers that.
Step 3: look prices up by lookup_key
Give the sandbox price and the live price the same lookup_key, for example pro_monthly. Then your code asks for the key, and each environment gets its own price ID. The Prices API accepts up to 10 lookup_keys per list call, and lookup keys exist so you don't hard-code prices.
import Stripe from 'stripe';
// Find the active price for a lookup key in whatever account and mode the key belongs to.
export async function resolvePrice(
stripe: Stripe,
lookupKey: string,
opts: { stripeAccount?: string } = {},
): Promise<Stripe.Price> {
const prices = await stripe.prices.list(
{ lookup_keys: [lookupKey], active: true, expand: ['data.product'], limit: 1 },
opts.stripeAccount ? { stripeAccount: opts.stripeAccount } : undefined,
);
const price = prices.data[0];
if (!price) {
const where = opts.stripeAccount ? `connected account ${opts.stripeAccount}` : 'this account';
throw new Error(`No active price with lookup_key "${lookupKey}" in ${where} for this key's mode`);
}
return price;
}active: true keeps archived prices out. When you change a price, create a new one with transfer_lookup_key: true, which moves the key in one step, then archive the old price. In production I cache the result for a few minutes so each checkout does not make an extra API call.
Step 4: pass stripeAccount for Connect
For direct charges the lookup and the session must both run on the connected account:
import Stripe from 'stripe';
import { resolvePrice } from './resolvePrice.js';
import { explainPriceError } from './priceErrors.js';
// Direct charge on a connected account: the price AND the session must use the same stripeAccount.
export async function createConnectedCheckout(
stripe: Stripe,
connectedAccountId: string, // acct_...
lookupKey: string,
origin: string,
) {
try {
const price = await resolvePrice(stripe, lookupKey, { stripeAccount: connectedAccountId });
return await stripe.checkout.sessions.create(
{
mode: price.recurring ? 'subscription' : 'payment',
line_items: [{ price: price.id, quantity: 1 }],
success_url: `${origin}/success?session_id={CHECKOUT_SESSION_ID}`,
cancel_url: `${origin}/pricing`,
},
{ stripeAccount: connectedAccountId },
);
} catch (err) {
const hint = explainPriceError(err);
if (hint) console.error(`[stripe] ${hint}`);
throw err;
}
}Step 5: log a useful message
This handler turns the error into something a person can act on. It only reacts when param is a price field, so a "No such customer" error is left alone.
import Stripe from 'stripe';
// Turn Stripe's "No such price" family of errors into a message that says what to check.
export function explainPriceError(err: unknown): string | null {
if (!(err instanceof Stripe.errors.StripeInvalidRequestError)) return null;
const param = err.param ?? '';
if (!/(^|\[)price\]?$/.test(param)) return null; // price, line_items[0][price], items[0][price]
const msg = err.message; // since stripe 23.2.0 this starts with "[req_...] ", so match with includes()
const where = `${param} (request ${err.requestId ?? 'unknown'})`;
if (err.code === 'resource_missing') {
if (msg.includes('similar object exists in live mode')) {
return `${where}: this is a LIVE price but the request used a TEST key. Use the test price ID or look it up by lookup_key.`;
}
if (msg.includes('similar object exists in test mode')) {
return `${where}: this is a TEST price but the request used a LIVE key. Create or copy the price in live mode and use its ID.`;
}
return `${where}: price not found in this account. Check the ID for typos or spaces, the Stripe account or sandbox it came from, and whether it lives on a connected account (stripeAccount option).`;
}
if (/inactive/i.test(msg)) {
return `${where}: the price is archived (active=false). Unarchive it or move the lookup_key to an active price.`;
}
return null;
}The inactive price check matches the text because I could not find a documented error code for that case. Real reports show the wording "The price specified is inactive. This field only accepts active prices." in the Firebase Stripe extension repo and in Paid Memberships Pro (July 2026).
How do I test this without a real Stripe account?
Mostly you can't test the real message, and I'd rather say so. stripe-mock is stateless: retrieve any price ID and it returns a sample price with that ID, so it never says "No such price". I used it to check that the request shapes are valid (lookup_keys, active, expand, a Checkout Session with Stripe-Account). For the error cases I ran a small local server that returns Stripe's error JSON and checked that stripe-node 23.2.0 parses it into the right error class. Output from node --test:
✔ key guard: matching test keys pass
✔ key guard: test secret key in a live environment throws
✔ key guard: live secret with test publishable key throws
✔ key guard: publishable key in the secret slot, empty value and trailing newline throw
✔ resolvePrice: stripe-mock accepts lookup_keys + active + expand and returns an expanded product
✔ resolvePrice: sends lookup_keys[], active=true, expand and the Stripe-Account header
✔ resolvePrice: empty list throws a clear error
✔ error: live price with test key is explained, message carries [req_...] prefix in stripe 23.2.0
✔ error: test price with live key is explained
✔ error: plain "No such price" points to account, sandbox and connected account
✔ error: archived price wording is recognised
✔ error: unrelated errors are ignored
✔ Connect: price lookup and session both carry Stripe-Account (stripe-mock validates params)
✔ stripe-mock is stateless: it returns any price ID, so it cannot reproduce "No such price"
ℹ tests 14
ℹ pass 14
ℹ fail 0If you want to see the real "similar object exists" sentence yourself, retrieve one of your live price IDs with your test key. It is a read, so nothing is charged.
How do I verify the fix?
stripe prices retrieve <id>with the deployed key returns the price, withlivemodeandactiveas expected.- Your startup log shows the mode the guard detected, and the server refuses to boot with a mismatched pair.
- In the Stripe Dashboard logs, the failed request is gone and the new one shows 200 for the right account and mode.
- A real checkout with a test card works in the sandbox (see my 3D Secure test cards guide), and one small live payment works in production.
How do I stop "No such price" coming back?
- No
price_strings in code. Search the repo forprice_and replace them with lookup keys. - One startup guard per server, failing fast on key mode mismatches.
- Every environment gets its own keys, webhook endpoint and signing secret. A mismatched webhook secret is the next thing that breaks on launch day; I covered it in Stripe webhook signature verification failed.
- When onboarding a new sandbox or account, set lookup keys on its prices before pointing any deployment at it.
- For Connect, store prices with the connected account ID next to them, and pass
stripeAccounton every call about them. - Log
err.code,err.paramanderr.requestId, never justerr.message.
Frequently asked questions
What does Stripe "No such price" mean?
The secret key that made the request cannot see the price ID you sent. Stripe returns HTTP 400 with the code resource_missing. The price may exist, but in another mode, another account, another sandbox or on a connected account.
What does "a similar object exists in live mode, but a test mode key was used" mean?
The price ID is real and was created in live mode, but your server called Stripe with a test key. Use the matching sandbox price, or look the price up by lookup key so each mode gets its own ID.
Why does my Stripe checkout fail after switching to live mode?
Usually the code still sends price IDs created in test mode. Live mode has separate objects, and Copy to live mode creates new price IDs, so put the live price IDs (or lookup keys) in your production settings and redeploy.
How do I fix "No such price" with Stripe Connect?
If the price was created on a connected account, pass the connected account ID with every request about it. In Node that is the stripeAccount request option, which sends the Stripe-Account header. The lookup and the Checkout Session must use the same account.
Can I use the same price ID in test mode and live mode?
No. Each mode and each sandbox has its own objects and IDs. Give both prices the same lookup key instead and fetch the price with prices.list and lookup_keys.
What error does Stripe return for an archived price?
Reports show "The price specified is inactive. This field only accepts active prices." The price exists but has active set to false. Unarchive it, or create a new price and move the lookup key to it.
How do I find my Stripe price ID?
Open the product in the Stripe Dashboard and copy the ID that starts with price_, making sure the Dashboard is on the same account, sandbox or live mode as your secret key. A product ID starting with prod_ will not work where a price is expected.
Sources
- Error codes (resource_missing, account_invalid) (Stripe)
- API keys (Stripe)
- Sandboxes (Stripe)
- Testing use cases (legacy test mode sandbox vs general sandboxes) (Stripe)
- Make API calls for connected accounts (Stripe)
- List all prices (lookup_keys) (Stripe)
- Manage products and prices (lookup keys, Copy to live mode, archive) (Stripe)
- API versioning (current version 2026-11-18.endive) (Stripe)
- stripe-node changelog 23.2.0 (Stripe on GitHub, 2026-11-18)
- stripe-node PR #2927: prefix request ID to error message (Stripe on GitHub, 2026-11-18)
- Stripe No such price: a similar object exists in live mode, but a test mode key was used (Stack Overflow, 2022-03-02)
- A similar object exists in test mode, but a live mode key was used (stripe-node #149) (GitHub, 2015-02-22)
- Stripe returning the wrong priceId when using Connect (Stack Overflow, 2024-02-07)
- The price specified is inactive (stripe-firebase-extensions #560) (GitHub, 2023-09-11)
- Skip archived/inactive Stripe prices (paid-memberships-pro #3717) (GitHub, 2026-07-13)
- stripe-mock (Stripe on GitHub, 2026-10-01)
- Environment variables (Vercel)
- Environment variables (NEXT_PUBLIC_ inlining) (Next.js)
Keep reading
- Stripe Webhook Signature Verification Failed in Next.js: FixStripe webhooks returning 400 in Next.js? Read the raw body with req.text(), use the right whsec secret and stop redirects. Tested route inside.
- Stripe 3D Secure Test Cards: Fix requires_action PaymentsThe Stripe 3D Secure test cards to use, why PaymentIntents get stuck in requires_action, and how to recover authentication_required off-session charges.
- Firebase Stripe Extension Shutdown: Move to Cloud FunctionsFirebase Extensions shut down on 31 Mar 2027. Replace the Run Payments with Stripe extension with your own Cloud Functions and keep the same Firestore data.
Comments
Share a question or note about this article.
Loading comments…