test/live mismatch API Origin: Application & API Last updated 14 Oct 2026

API Error: a similar object exists in test mode, but a live mode key was used

You’re using an ID, key or URL from one environment (test/sandbox) with credentials from another (live/production), or vice versa.

Exact message you may see a similar object exists in test mode, but a live mode key was useda similar object exists in live mode, but a test mode key was usedtest mode keylive mode keysandbox credentials
Seen on: REST API

Meaning

Payment and SaaS APIs keep test and live data completely separate. Stripe says “No such customer: 'cus_x'; a similar object exists in test mode, but a live mode key was used to make this request”. Other providers return 401 “invalid key for this environment” or simply “not found”.

It typically happens after going live: the keys were swapped but IDs (prices, plans, webhooks, customers) saved in the database or config are still test-mode IDs — or the frontend uses a test publishable key while the backend uses a live secret key.

Common causes

  • Test-mode IDs (price, plan, product, customer) stored in config after switching to live keys
  • Frontend and backend use keys from different modes
  • Sandbox base URL with production credentials (or the reverse)
  • Data copied from staging to production

⚡ Quick fix

  1. Use keys and IDs from the same mode everywhere
  2. Recreate products/prices/webhooks in live mode and update stored IDs
  3. Keep mode-specific settings in per-environment config

Detailed fix by platform

Node.js

  1. javascript
    // fail fast if keys from different modes are mixed
    const live = process.env.STRIPE_SECRET_KEY.startsWith('sk_live_');
    if (live !== process.env.STRIPE_PUBLISHABLE_KEY.startsWith('pk_live_')) throw new Error('Stripe keys are from different modes');

How to diagnose

  1. Keys — Prefixes of secret and publishable keys (sk_live/sk_test)
  2. IDs — Where were stored IDs created?
  3. URLs — Sandbox vs production base URL

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

Where this error sits

Origin: Application & API. Errors that are often confused with or caused by this one (click to open):

1000 — Cloudflare Error 1000: DNS points to prohibited IP (Cloudflare)10001046 — MySQL ERROR 1046 (3D000): No database selected (MySQL)10461049 — MySQL ERROR 1049 (42000): Unknown database 'x' (MySQL)10491153 — MySQL ERROR 1153 (08S01): Got a packet bigger than 'max_allowed_packet' bytes (MySQL)11533D000 — FATAL: database "x" does not exist (PostgreSQL)3D000AADSTS90002 — AADSTS90002: Tenant 'x' not found (Azure)AADSTS90002AH00558 — Apache: AH00558: apache2: Could not reliably determine the server's fully qualified domain name (Nginx / Apache)AH00558api_version_invalid — API Error: Invalid or unsupported API version (API)api_version_invalidtest/live…

Explore the map of this error Full error map →

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.

💬 What worked for others

No tips yet — did something else fix this for you?

Share what worked for you

Tips are checked by an editor before they appear. Links are removed.