Common Issues
This guide covers frequent issues developers may encounter when working with RLink and their solutions.Authentication Issues
Cannot Log In - “Invalid Credentials”
Symptoms: Login fails even with correct email and password Possible Causes:- User account doesn’t exist in database
- Password hash mismatch
- Email not verified (if verification required)
- Session configuration issue
Session Expires Immediately
Symptoms: User logs in successfully but is immediately logged out or session expires Possible Causes:- Cookie domain mismatch
- HTTPS/HTTP mismatch
NEXT_PUBLIC_APP_URLincorrect- Session secret changed
Check Cookie Settings
Check Cookie Settings
Verify Environment Variables
Verify Environment Variables
Clear Cookies and Cache
Clear Cookies and Cache
2FA Code Not Accepting
Symptoms: 2FA code rejected even when entered correctly Possible Causes:- Time sync issue between server and authenticator app
- Code already used (codes are single-use)
- Wrong secret configured
-
Check Server Time: Ensure server time is accurate
-
Re-setup 2FA:
- Go to Settings → Security
- Disable 2FA
- Re-enable and scan new QR code
- Test immediately
- Use Backup Codes: If provided during setup, use backup codes to access account
Database Issues
”Connection Timeout” Error
Symptoms: Application cannot connect to database Possible Causes:- Database is paused/inactive (Neon)
- Wrong connection string
- SSL mode not configured
- Network/firewall blocking connection
Verify Database is Active
Check Neon dashboard - database may be in suspended state. Click to wake it up.
Migration Errors
Symptoms:drizzle-kit migrate fails with SQL errors
Possible Causes:
- Migration already applied
- Schema conflicts
- Manual database changes conflicting with migrations
Check Migration Status
Check Migration Status
Connect to database and check:This shows which migrations have been applied.
Reset Migrations (Development Only)
Reset Migrations (Development Only)
⚠️ WARNING: This will delete all data
Manual Migration Fix
Manual Migration Fix
If a specific migration fails:
- Review the generated SQL in
drizzle/folder - Apply the failing parts manually via psql
- Mark migration as applied in
__drizzle_migrationstable
”Too Many Connections” Error
Symptoms: Database rejects new connections Possible Causes:- Connection pool exhausted
- Connections not being closed properly
- Too many concurrent API requests
- Enable Connection Pooling in Neon dashboard
-
Check for Connection Leaks:
-
Implement Connection Limits:
API Issues
CORS Errors in Browser
Symptoms:CORS policy: No 'Access-Control-Allow-Origin' header
Possible Causes:
ALLOWED_ORIGINenvironment variable incorrect- Request from wrong origin
- Credentials not included in request
Check Request Origin
In browser DevTools → Network → failed request:
- Check
Originheader in request - Should match
ALLOWED_ORIGIN
500 Internal Server Error
Symptoms: API returns 500 status code Possible Causes:- Unhandled exception in API route
- Database query error
- Missing environment variable
Check Server Logs
Check Server Logs
Development:
Check terminal where
npm run dev is runningProduction (Vercel):- Go to Vercel dashboard
- Select deployment
- Click “Functions” tab
- View error logs
Add Error Logging
Add Error Logging
Wrap API logic in try-catch:
Verify Environment Variables
Verify Environment Variables
All required variables set in production:
Rate Limit Exceeded
Symptoms: API returns 429 status code Possible Causes:- Too many requests from same IP/user
- Rate limit threshold too low
- Infinite loop making requests
- Wait and Retry: Rate limits reset after time period
-
Check for Request Loops:
- Adjust rate limits: If traffic is legitimate, raise limits in your middleware or edge configuration.
Email Issues
Emails Not Sending
Symptoms: Users don’t receive welcome emails, password resets, etc. Possible Causes:- Invalid Resend API key
- Sending domain not verified
- Email in spam folder
- Resend account limits reached
Check Resend Dashboard
- Go to resend.com/emails
- Check “Logs” for delivery status
- Look for error messages
Verify Domain
In Resend dashboard:
- Go to Domains
- Ensure domain has green checkmark
- Add DNS records if not verified
Email Templates Not Rendering
Symptoms: Emails send but look broken or unstyled Possible Causes:- React Email component error
- Missing styles
- Email client compatibility
-
Preview Templates Locally:
Open http://localhost:3000 to preview templates
-
Check Template Syntax:
- Test Across Email Clients: Use Litmus or similar to test rendering
Performance Issues
Slow Page Load Times
Symptoms: Pages take >3 seconds to load Possible Causes:- Large database queries without pagination
- Missing indexes on database
- Too many API calls
- Large images not optimized
Enable Pagination
Enable Pagination
Add Database Indexes
Add Database Indexes
Use TanStack Query Caching
Use TanStack Query Caching
Optimize Images
Optimize Images
Use Next.js Image component:
Memory Leaks
Symptoms: Application becomes slow over time, eventual crashes Possible Causes:- Event listeners not cleaned up
- Timers not cleared
- Large objects kept in memory
Build & Deployment Issues
Build Fails on Vercel
Symptoms: Deployment fails during build step Possible Causes:- TypeScript errors
- Missing environment variables
- Dependency issues
Vercel Function Timeout
Symptoms: API routes timeout after 10 seconds Possible Causes:- Slow database queries
- External API calls taking too long
- Heavy computation
- Optimize Queries: Add indexes, reduce data fetched
- Upgrade Vercel Plan: Pro/Enterprise have longer timeouts (60s-900s)
-
Move to Background Job:
Development Environment Issues
Module Not Found
Symptoms: Import errors likeCannot find module '@/lib/db'
Possible Causes:
- TypeScript path aliases not configured
- Missing dependencies
- Wrong import path
Check tsconfig.json
Check tsconfig.json
Reinstall Dependencies
Reinstall Dependencies
Fix Import Path
Fix Import Path
Hot Reload Not Working
Symptoms: Changes to files don’t trigger page refresh Possible Causes:- File watcher limit reached
- Next.js cache issue
- Wrong file location
-
Increase File Watcher Limit (Linux/Mac):
-
Clear Next.js Cache:
-
Restart Dev Server: Stop and restart
npm run dev
Development and deployment edge cases
Preview URLs vs production (Vercel)
Vercel preview deployments get a different hostname on every branch. SetNEXT_PUBLIC_APP_URL (and related auth URLs) to match the environment you are testing. A cookie issued on localhost will not work on a preview URL, and mixing http and https breaks sessions.
Windows vs macOS/Linux
- Line endings — If scripts fail mysteriously, check Git
core.autocrlfand ensure shell scripts use LF where required. - Environment variables — In PowerShell, use
$env:VAR=valuefor one-off commands; in Command Prompt, useset VAR=value. - Port 3000 — See Getting started for PowerShell and bash commands to free a port.
Database and Neon
- Cold starts / timeouts — First request after idle can be slower; connection pooling (Neon serverless) or retry logic may be needed for scripts.
- SSL — Production
DATABASE_URLshould usesslmode=require(or your provider’s equivalent). drizzle-kit pushon production — Can drift from migration history. Prefergenerate+migratefor anything that matters.
Cron and secured routes
Scheduled jobs that call/api/cron/* must send the Authorization header (or mechanism) your route expects—typically CRON_SECRET on Vercel. Missing or wrong secrets return 401 or 403 with no obvious UI hint.
CORS and ALLOWED_ORIGIN
Browser calls from another origin to RLink APIs must match ALLOWED_ORIGIN and cookie rules. Symptoms: preflight failures, or 401 with no session cookie. Align the origin with your deployment docs in Deployment.
API clients and cookies
Server-side fetch from Next.js to your own API can omit cookies if you do not forward them.fetch from the browser after login usually includes cookies automatically. For Postman or curl, you must copy session cookies from the browser after login.
Getting more help
If your issue isn’t covered here:Check Logs
- Browser console (F12)
- Server terminal output
- Vercel deployment logs
Search Issues
Search for similar issues in:
- Next.js GitHub issues
- Better Auth documentation
- Drizzle ORM discussions
When reporting issues, always include:
- Error message (full stack trace)
- Steps to reproduce
- Environment (dev/production)
- Browser/Node version
