Troubleshooting Guide
Common Issues and Solutions
API Won't Start - ENCRYPTION_KEY Error
Error Message:
Error: ENCRYPTION_KEY environment variable is requiredSolution:
-
Check if
.env.localexists in the project root:ls -la .env.local -
If it doesn't exist, create it:
cp env.example .env.local -
Generate an encryption key:
openssl rand -base64 32 -
Edit
.env.localand set the ENCRYPTION_KEY:ENCRYPTION_KEY=<paste the generated key here> -
Restart the API server
Note: The API looks for .env.local in the project root directory.
Form Submits But Nothing Happens
Symptoms:
- Clicking "Test & Connect" closes the modal
- No error message appears
- Connection doesn't appear in the list
Possible Causes:
-
API is not running
- Check if API is accessible: http://localhost:3001/health (opens in a new tab)
- Check terminal for API errors
- Verify API process is running
-
CORS issues
- Check browser console for CORS errors
- Verify
NEXT_PUBLIC_API_URLis correct - Check API logs for CORS rejection
-
API errors
- Check API terminal output for errors
- Check browser Network tab for failed requests
- Look at response status codes
Solution:
-
Verify API is running:
curl http://localhost:3001/healthShould return:
{"status":"ok",...} -
Check browser console:
- Open Developer Tools (F12)
- Go to Console tab
- Look for error messages
- Go to Network tab
- Try submitting form again
- Check the request to
/api/connections - Look at the response
-
Check API logs:
- Look at the terminal where
pnpm devis running - Check for error messages from the API
- Look at the terminal where
Database Connection Errors
Error Message:
connection refused
ECONNREFUSEDSolution:
-
Verify PostgreSQL is running:
pg_isready # or psql -U postgres -c "SELECT 1" -
Check DATABASE_URL in
.env.local:DATABASE_URL=postgres://username:password@localhost:5432/unifiedcron -
Create the database if it doesn't exist:
createdb unifiedcron # or psql -U postgres -c "CREATE DATABASE unifiedcron;" -
Run migrations:
cd packages/database pnpm build node dist/migrate.js
Frontend Can't Connect to API
Symptoms:
- Frontend loads but shows errors
- "Failed to fetch" errors in console
- API calls return errors
Solution:
-
Verify API URL:
- Check
.env.localhas:NEXT_PUBLIC_API_URL=http://localhost:3001 - Restart frontend after changing this
- Check
-
Check API is accessible:
curl http://localhost:3001/health -
Check CORS settings:
- API should allow
http://localhost:3000 - Check API logs for CORS errors
- API should allow
-
Verify ports:
- API should be on 3001
- Frontend should be on 3000
- Check for port conflicts:
lsof -i :3001
Connection Test Fails
Symptoms:
- Connection test returns error
- "Failed to connect to Supabase" message
Solution:
-
Verify Supabase setup:
- Run SQL from
docs/supabase-setup.sqlin Supabase SQL Editor - Verify views exist:
cron_jobs_viewandcron_job_run_logs
- Run SQL from
-
Check credentials:
- Project URL should be:
https://xxxxx.supabase.co - Anonymous Key should start with:
eyJ... - Verify credentials in Supabase dashboard
- Project URL should be:
-
Test connection manually:
# Use the test script ./scripts/test-supabase-connection.sh <project-url> <anon-key> -
Check API logs:
- Look for detailed error messages
- Verify the request reaches Supabase
No Jobs Discovered
Symptoms:
- Connection created successfully
- No jobs appear in dashboard
Solution:
-
Verify you have cron jobs in Supabase:
SELECT * FROM cron.job WHERE active = true; -
Check views are accessible:
SELECT * FROM cron_jobs_view LIMIT 1; -
Refresh jobs manually:
- Go to Dashboard
- Click "Refresh Jobs" on the connection
- Check for errors
-
Verify connection details:
- Re-test the connection
- Check connection status
Debug Checklist
Before asking for help, please check:
-
.env.localexists and hasENCRYPTION_KEYset - PostgreSQL is running and accessible
- Database exists and migrations have run
- API server is running (check http://localhost:3001/health (opens in a new tab))
- Frontend is running (check http://localhost:3000 (opens in a new tab))
- Browser console shows no errors
- API logs show no errors
- Supabase views are created (run SQL setup)
- Supabase credentials are correct
Getting More Help
-
Check logs:
- API logs: Terminal running
pnpm dev - Frontend logs: Browser console
- Database logs: PostgreSQL logs
- API logs: Terminal running
-
Gather information:
- Error messages from console
- API response codes from Network tab
- Environment configuration (remove secrets)
- Steps to reproduce
-
Test individual components:
- Test API health endpoint
- Test database connection
- Test Supabase connection manually
- Test API endpoints with curl
Quick Fixes
Reset Everything
- Stop all processes (Ctrl+C)
- Check and fix
.env.local - Verify database is accessible
- Restart:
pnpm dev
Clear Browser Cache
- Hard refresh: Cmd+Shift+R (Mac) or Ctrl+Shift+R (Windows)
- Or clear browser cache
- Or open in incognito/private mode
Restart Database
# If using local PostgreSQL
pg_ctl restart
# If using Docker
docker compose restart postgres