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 theVITE_prefix. - The deployed site still has
pk_test_on a production instance, orpk_live_on a domain Clerk has not allowed. Production keys only work on the configured production domain. Clerk's message for localhost isClerk: 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
- 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_. - On Vercel, set
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEYfor a Next.js app, orVITE_CLERK_PUBLISHABLE_KEYfor Vite. SetCLERK_SECRET_KEYto the matching secret, withoutNEXT_PUBLIC_orVITE_. - 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.
- 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. - 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
- https://clerk.com/docs/guides/development/troubleshooting/script-loading (opens in a new tab)
- https://clerk.com/docs/guides/development/clerk-environment-variables (opens in a new tab)
- https://clerk.com/docs/guides/development/deployment/production (opens in a new tab)
- https://clerk.com/docs/errors/frontend-api (opens in a new tab)
- https://clerk.com/docs/guides/development/troubleshooting/using-production-keys-in-development (opens in a new tab)
Related fixes
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.