3.2 KiB
3.2 KiB
Fix: ENOTFOUND Database Hostname Error
Problem
You're seeing: ENOTFOUND db.mycttyevrycmkhlvwgfk.supabase.co
This means the hostname cannot be resolved. Common causes:
- Project is paused in Supabase
- Using wrong connection string format
- Need to use Pooler connection instead
Solution 1: Use Connection Pooler (RECOMMENDED)
Supabase provides a connection pooler that's more reliable:
-
Go to Supabase Dashboard → Settings → Database
-
Find "Connection Pooling" section
-
Select "Transaction" mode (or "Session" if you need transactions)
-
Copy the connection string - it will look like:
postgresql://postgres:[YOUR-PASSWORD]@mycttyevrycmkhlvwgfk.pooler.supabase.com:6543/postgresOR
postgresql://postgres:[YOUR-PASSWORD]@mycttyevrycmkhlvwgfk.pooler.supabase.com:5432/postgres -
Update your
.envfile:DATABASE_URL=postgresql://postgres:your_password@mycttyevrycmkhlvwgfk.pooler.supabase.com:6543/postgres
Key differences:
- Uses
.pooler.supabase.cominstead ofdb.xxx.supabase.co - Port is usually
6543(transaction mode) or5432(session mode) - More reliable for serverless/cloud deployments
Solution 2: Check Project Status
- Go to Supabase Dashboard
- Check if your project shows as "Paused" or "Inactive"
- If paused, click "Restore" to reactivate it
- Wait a few minutes for DNS to propagate
- Try connecting again
Solution 3: Use Supabase Client Instead
If direct connection doesn't work, use Supabase client:
-
Get your API keys:
- Go to Supabase Dashboard → Settings → API
- Copy:
- Project URL:
https://mycttyevrycmkhlvwgfk.supabase.co - service_role key (secret)
- Project URL:
-
Update your
.envfile:# Remove or comment out DATABASE_URL # DATABASE_URL=... # Add Supabase client config SUPABASE_URL=https://mycttyevrycmkhlvwgfk.supabase.co SUPABASE_SERVICE_KEY=your_service_role_key_here -
Restart server
Solution 4: Verify Connection String Format
Make sure your connection string has the correct format:
Direct connection (if project is active):
postgresql://postgres:password@db.project-ref.supabase.co:5432/postgres
Pooler connection (recommended):
postgresql://postgres:password@project-ref.pooler.supabase.com:6543/postgres
Common mistakes:
- ❌ Missing
postgresql://prefix - ❌ Wrong port (should be 5432 or 6543)
- ❌ Missing password brackets
[password]should be replaced with actual password - ❌ Using
db.prefix with pooler (pooler doesn't usedb.)
Quick Test
After updating your .env file, test the connection:
cd backend
npm run dev
You should see:
✅ Database connection successful (PostgreSQL direct)
Or:
✅ Database connection successful (Supabase)
Still Not Working?
- Check your network/firewall - Make sure port 5432 or 6543 is not blocked
- Try pinging the hostname:
ping mycttyevrycmkhlvwgfk.pooler.supabase.com - Verify project is active in Supabase Dashboard
- Check Supabase status page for any outages
- Contact Supabase support if project appears active but connection fails