Guide 3 of 4
Troubleshooting
Fast fixes for common setup errors
Why does setup use a “dev” Convex URL (*.convex.cloud)?
Convex has two deployments per project:
- Development —
npx convex dev --once, localnpm run dev - Production — Vercel,
npm run build/convex deploy, buyer traffic
convex dev --once always pushes to Development. That is expected. Your live portfolio on Vercel still uses Production URLs and env vars (--prod).
Setup fails on Development env with 401 MissingAccessToken
Cause:
CONVEX_DEPLOY_KEYonly works for Production (--prod).- If that key is in your shell or
.env.local, the CLI skips your login token and Development commands fail.
Fix:
unset CONVEX_DEPLOY_KEY
export CONVEX_DEPLOYMENT=dev:your-project-slug
npx convex env set SITE_URL http://localhost:3000
npx convex env set BETTER_AUTH_SECRET "your-secret"
Do not put CONVEX_DEPLOY_KEY in .env.local (Vercel only).
Setup fails with No CONVEX_DEPLOYMENT set
Cause:
convex env set(Development) only works after the project is linked.- Linking happens in
npx convex dev --once, which writesCONVEX_DEPLOYMENTto.env.local.
Fix:
- Run
npx convex login - Run
npx convex dev --onceand finish the prompts (create or choose a project) - Run
npm run setupagain, or set Development env vars manually:
npx convex env set SITE_URL http://localhost:3000
npx convex env set BETTER_AUTH_SECRET "your-secret-here"
Setup fails at npx convex dev --once with SITE_URL is not set in Convex
Cause:
- Development deployment is missing
SITE_URL/BETTER_AUTH_SECRET(auth needs them at runtime).
Fix:
- Finish
npx convex dev --onceif linking succeeded - Set Development env vars (dashboard or CLI commands above)
- Re-run
npm run setupor continue the wizard
Production (--prod) vars are still set later in setup for your live Vercel URL.
Build fails with SITE_URL is not set in Convex
Cause:
- Convex Production env var
SITE_URLis missing (or set on wrong deployment).
Fix:
- Convex dashboard → Project → Settings → Environment Variables (Production)
- Set:
SITE_URL=https://your-vercel-urlBETTER_AUTH_SECRET=<same as Vercel>
- Run setup again or redeploy on Vercel
Invalid origin on login
Cause:
- URL mismatch between app and Convex auth env.
Fix:
- Vercel
NEXT_PUBLIC_SITE_URLmust equal ConvexSITE_URL(Production) - Both should be your live app URL
Redirect loop / 508 auth errors
Cause:
NEXT_PUBLIC_CONVEX_SITE_URLset to app URL instead of Convex site URL.
Fix:
- Use Convex URL ending in
.convex.site - Do not use
https://your-app.vercel.appfor this variable
Setup gets stuck after login commands
If CLI interaction is interrupted:
- Press
Ctrl+C - Run
npm run setupagain - Answer prompts again
The wizard is safe to re-run.
Vercel assigned a different domain than expected
Example:
- expected
https://my-site.vercel.app - got
https://my-site-abc123.vercel.app
Fix:
Update both:
- Vercel
NEXT_PUBLIC_SITE_URL - Convex
SITE_URL(Production)
Then redeploy.
Note:
- Current setup wizard auto-detects this mismatch and offers to fix/redeploy for you.