Troubleshooting
Common issues and how to resolve them
Troubleshooting
Quick solutions to common issues. Most problems are related to environment variables, Convex configuration, or email setup.
Quick Fixes
Before diving into specific issues, try these first:
- Restart the dev server: Stop and restart
npm run dev - Restart Convex: Stop and restart
npx convex dev - Clear browser cookies: Especially for auth issues
- Check environment variables: Ensure all are set correctly
- Check Convex dashboard: Look for errors in function logs
Authentication Issues
Can't Sign In
Symptoms:
- Login form submits but nothing happens
- Error messages about invalid credentials
- Redirect loops
Solutions:
-
Check email verification:
- Users must verify their email before signing in
- Check if verification email was sent
- Try resending verification email
-
Verify Convex connection:
npx convex devEnsure Convex is running and connected.
-
Check
BETTER_AUTH_SECRET:- Must be the same in
.env.localand Convex - Generate a new one if unsure:
openssl rand -base64 32 - Must be the same in
-
Check
BETTER_AUTH_URL:- Must match your actual URL
- For local:
http://localhost:3000 - For production:
https://yourdomain.com
-
Clear cookies and try again:
- Open DevTools → Application → Cookies
- Delete all cookies for your domain
- Try signing in again
Session Issues
Symptoms:
- Getting logged out unexpectedly
- Session not persisting
- "Unauthorized" errors
Solutions:
-
Check cookie settings:
- Cookies require HTTPS in production
- Ensure
BETTER_AUTH_URLuses correct protocol
-
Verify secret consistency:
BETTER_AUTH_SECRETmust match everywhere- If you changed it, all existing sessions are invalid
-
Check session expiration:
- Sessions expire after configured time
- Users need to sign in again after expiration
2FA Not Working
Symptoms:
- TOTP codes rejected
- "Invalid code" errors
- Can't complete 2FA setup
Solutions:
-
Check device time:
- TOTP codes are time-based
- Device clock must be accurate
- Enable automatic time sync
-
Try backup codes:
- Each backup code works once
- 12 codes are generated during setup
-
Wait for next code:
- Codes refresh every 30 seconds
- If timing is close, wait for next code
-
Re-setup 2FA:
- Disable and re-enable 2FA
- Scan QR code again
- Save new backup codes
Passkeys Not Working
Symptoms:
- Can't register passkey
- Passkey authentication fails
- "Origin mismatch" errors
Solutions:
-
Check
PASSKEY_RP_ID:- Must match your domain exactly
- No protocol (just
yourdomain.com) - For local: use
localhost
-
Ensure HTTPS:
- Passkeys require HTTPS (except localhost)
- Check SSL certificate is valid
-
Check browser support:
- Use Chrome, Safari, Firefox, or Edge
- Must be recent version
- WebAuthn must be enabled
-
Check device settings:
- Biometrics must be enabled
- Device must support WebAuthn
Email Issues
Emails Not Sending
Symptoms:
- No verification email received
- Password reset email not arriving
- Invitation emails failing
Solutions:
-
Check Resend API key:
npx convex env set RESEND_API_KEY "re_your_key" -
Verify
EMAIL_FROM:- Must use verified domain
- Format:
"Name <email@domain.com>"
-
Check Resend dashboard:
- View sent emails
- Check for errors
- Verify domain status
-
Check spam folder:
- Verification emails often land in spam
- Mark as "not spam" to improve delivery
-
Test mode limitations:
- In test mode, only verified emails receive mail
- Use your own verified email for testing
Emails Going to Spam
Solutions:
-
Verify your domain:
- Add DNS records in Resend
- Wait for verification (can take hours)
-
Configure SPF/DKIM/DMARC:
- Resend provides these records
- Add all required DNS entries
-
Use proper sender address:
- Use subdomain like
mail.yourdomain.com - Avoid generic addresses
- Use subdomain like
-
Warm up your domain:
- Start with low volume
- Gradually increase sending
Convex Issues
Connection Failed
Symptoms:
- "Failed to connect to Convex"
- Real-time updates not working
- Queries returning undefined
Solutions:
-
Check Convex is running:
npx convex dev -
Verify Convex URLs:
CONVEX_DEPLOYMENT="dev:your-deployment" NEXT_PUBLIC_CONVEX_URL="https://your-deployment.convex.cloud" NEXT_PUBLIC_CONVEX_SITE_URL="https://your-deployment.convex.site" -
Check Convex dashboard:
- Login to dashboard.convex.dev
- Verify deployment exists
- Check for errors in logs
-
Reinstall Convex:
npm install convex npx convex dev
Schema Errors
Symptoms:
- "Schema validation failed"
- Type errors in Convex functions
- Deployment fails
Solutions:
-
Check schema.ts:
- Ensure all fields have valid types
- Check for syntax errors
-
Run type check:
npx convex devConvex validates schema on startup.
-
Reset and redeploy:
npx convex deploy --yes
Function Errors
Symptoms:
- Queries/mutations failing
- Error messages in console
- Unexpected behavior
Solutions:
-
Check Convex logs:
- Open Convex dashboard
- Go to Logs section
- Find the failing function
-
Add error handling:
export const myFunction = query({ handler: async (ctx) => { try { // Your code } catch (error) { console.error("Function failed:", error); throw error; } }, }); -
Test locally first:
- Use Convex dashboard to test functions
- Check input arguments
Environment Variable Issues
Variable Not Found
Symptoms:
- "Environment variable undefined"
- Features not working
- Deployment errors
Solutions:
-
Check
.env.localexists:ls -la .env.local -
Verify variable names:
- Case-sensitive
- No spaces around
= - No quotes issues
-
Restart dev server:
- Environment changes require restart
- Stop and restart
npm run dev
-
Set in Convex:
npx convex env set VARIABLE_NAME "value" -
Check which env file is loaded:
.env.localfor development- Vercel/platform env for production
Secret Mismatch
Symptoms:
- Auth randomly failing
- "Invalid token" errors
- Sessions not working
Solutions:
-
Sync secrets:
BETTER_AUTH_SECRETmust be identical in:.env.local- Convex environment
- Production environment
-
Generate new secret:
openssl rand -base64 32Update everywhere.
-
Clear all sessions:
- Old sessions won't work with new secret
- Users need to sign in again
Build Issues
Build Fails
Symptoms:
npm run buildfails- TypeScript errors
- Module not found
Solutions:
-
Check TypeScript errors:
npx tsc --noEmit -
Install dependencies:
rm -rf node_modules npm install -
Clear Next.js cache:
rm -rf .next npm run build -
Check import paths:
- Use
@/alias correctly - Ensure files exist
- Use
Production Deployment Fails
Solutions:
-
Check all env vars are set:
- In Vercel dashboard
- For production environment
-
Match local build:
npm run buildFix any errors locally first.
-
Check Vercel logs:
- Deployment logs show errors
- Function logs show runtime errors
Organization Issues
Can't Create Organization
Solutions:
-
Check user is authenticated:
- Must be logged in
- Email must be verified
-
Check Autumn is configured:
AUTUMN_API_KEYmust be set- Or billing must be removed
Can't Add Members
Solutions:
-
Check Pro plan:
- Organization must be on Pro plan
- Upgrade first, then add members
-
Check permissions:
- Only owners and admins can add members
- Verify user role
-
Check billing status:
- Subscription must be active
- No payment failures
Invitations Not Working
Solutions:
-
Check email is sending:
- Verify Resend is configured
- Check Resend logs
-
Check invitation status:
- View in organization dashboard
- Resend if needed
-
Check user account:
- Invitee may need to create account first
- Email must match invitation
Admin Panel Issues
Can't Access Admin
Solutions:
-
Check admin role:
- User must have
adminrole - Set in Convex dashboard
- User must have
-
Set first admin:
- Go to Convex dashboard
- Navigate to
betterAuth→users - Edit your user's role to
admin
User Actions Failing
Solutions:
-
Check permissions:
- Can't ban yourself
- Can't impersonate other admins
- Can't delete your own account
-
Check user exists:
- User may have been deleted
- Refresh the page
Performance Issues
Slow Page Loads
Solutions:
-
Check Convex queries:
- Avoid fetching too much data
- Use indexes for filters
-
Use pagination:
- Don't load all records at once
- Implement cursor-based pagination
-
Check network:
- Slow connection affects real-time updates
- Check Convex region is close to users
Memory Issues
Solutions:
-
Check for memory leaks:
- Monitor with DevTools
- Check for unsubscribed listeners
-
Optimize images:
- Use Next.js Image component
- Compress large images
Getting More Help
If you're still stuck:
-
Check logs:
- Browser console
- Convex dashboard logs
- Vercel deployment logs
-
Search documentation:
- Convex Docs
- better-convex Docs - Our Better Auth + Convex integration
- Better Auth Docs
- Next.js Docs
-
Common error messages:
- Search the exact error message
- Check GitHub issues for the libraries
-
Contact support:
- Provide detailed error messages
- Include relevant configuration
- Describe steps to reproduce
Most issues are environment-related. Double-check all environment variables are set correctly in both .env.local and Convex.