Clerk: Missing or invalid Publishable Key

Clerk says Missing or invalid Publishable Key on Vercel? Set NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY or VITE_CLERK_PUBLISHABLE_KEY to the pk_live_ key, then redeploy.

Reviewed October 18, 2026

What it means in plain English

Clerk's script-loading guide lists "Missing or invalid Publishable Key" as one reason Clerk does not finish loading. The Frontend API can also return InvalidHost (host_invalid) with the long message "We were unable to attribute this request to an instance running on Clerk. Make sure that your Clerk Publishable Key is correct."

Clerk's env-var guide says the Next.js name is NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY and the Vite name is VITE_CLERK_PUBLISHABLE_KEY. Development keys start with pk_test_. Production keys start with pk_live_. The secret is CLERK_SECRET_KEY (sk_test_ or sk_live_) and must not be exposed with a public prefix. The docs do not use the exact phrase "publishable key not valid".

Likely causes

  • The host has no publishable key, so the production build has an empty value. See Environment variables are undefined in production.
  • The Vite app is reading NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY. Clerk says Vite needs the VITE_ prefix.
  • The deployed site still has pk_test_ on a production instance, or pk_live_ on a domain Clerk has not allowed. Production keys only work on the configured production domain. Clerk's message for localhost is Clerk: Production Keys are only allowed for domain "your-domain.com". The test-versus-live swap is Clerk production is still using pk_test_ keys.

How to fix it, step by step

  1. In the Clerk Dashboard, open the API keys page and copy the publishable key for the instance this deploy should use. Production is pk_live_.
  2. On Vercel, set NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY for a Next.js app, or VITE_CLERK_PUBLISHABLE_KEY for Vite. Set CLERK_SECRET_KEY to the matching secret, without NEXT_PUBLIC_ or VITE_.
  3. Redeploy. Clerk's production guide says to update the values on the host and redeploy. Changing the dashboard does not rewrite an already-built site.
  4. If the error is InvalidHost, the key and the host do not belong to the same instance. Use the key from the instance whose domain is this site.
  5. Do not point production keys at localhost. Clerk says that origin is rejected.

How to check it worked

  • The live page loads Clerk's sign-in UI.
  • The console no longer says "Missing or invalid Publishable Key".
  • The published bundle contains pk_live_ for a production instance, and the secret is not in that bundle.

Sources

More Environment variables fixes

More Clerk fixes

Keep going on your own.

The guides stay free. A deep leak report is $15. Fix packs are $24, or $49 for all three. There is no done-for-you repair.

See products