Clerk·Fixauthbeginner

Clerk Login Works Locally but Fails After Deploy

Quick Answer

How do I fix Clerk Login Works Locally but Fails After Deploy?

Production domain not added to Clerk, or using development keys in production. Start with "Add production domain to Clerk" before making broader code changes.

Fix signals

What this answers
Why clerk login works locally but fails after deploy happens and what to change first.
Fastest move
Add production domain to Clerk
Use this page if
Login works locally but fails in production

If this keeps happening

Open the next decision, not just the patch

Use these when the current fix is helpful, but the real answer is a better tool choice, a cleaner workflow layer, or a more trustworthy launch path.

Quick Fix Summary

Most likely causeProduction domain not added to Clerk, or using development keys in production.
Fastest fixAdd production domain to Clerk
Use this page ifLogin works locally but fails in production

Exact errors people search for

If one of these matches what you are seeing, you are likely on the right fix page.

Clerk login works locally but fails after deploy
After login the app gets stuck in a redirect loop
Clerk returns unauthorized on the live domain

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

1

Add production domain to Clerk

Clerk Dashboard → your app → Domains → Add your production domain.

2

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