Clerk Authentication Not Working After Deploy
Quick Answer
Production domain not added to Clerk, or using development keys in production. Start with "Add production domain to Clerk" before making broader code changes.
You're in the right place if...
- !Login works locally but fails in production
- !Redirect loop after login
- !Clerk returns unauthorized error
Why this happens
Production domain not added to Clerk, or using development keys in production.
Fix
Add production domain to Clerk
Clerk Dashboard → your app → Domains → Add your production domain.
Add production env vars to Vercel
Switch from dev to production keys:
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=pk_live_... CLERK_SECRET_KEY=sk_live_... NEXT_PUBLIC_CLERK_SIGN_IN_URL=/sign-in NEXT_PUBLIC_CLERK_SIGN_UP_URL=/sign-up NEXT_PUBLIC_CLERK_AFTER_SIGN_IN_URL=/dashboard NEXT_PUBLIC_CLERK_AFTER_SIGN_UP_URL=/dashboard
Prevent this next time
Add your production domain to Clerk BEFORE deploying. Use separate Clerk instances for dev and production.
Frequently Asked Questions
Dev keys (pk_test_) work on localhost. Production keys (pk_live_) work on your real domain. Use the right ones.
You can, but it's better to create separate instances. This prevents dev testing from affecting production users.
Related fixes
Weekly Newsletter
Get next week's fix before you need it.
Join developers getting weekly vibe coding tips, error fixes, and tool updates.
Subscribe on Substack →