117 lines
3.2 KiB
Markdown
117 lines
3.2 KiB
Markdown
# Fix: ENOTFOUND Database Hostname Error
|
|
|
|
## Problem
|
|
You're seeing: `ENOTFOUND db.mycttyevrycmkhlvwgfk.supabase.co`
|
|
|
|
This means the hostname cannot be resolved. Common causes:
|
|
1. Project is paused in Supabase
|
|
2. Using wrong connection string format
|
|
3. Need to use Pooler connection instead
|
|
|
|
## Solution 1: Use Connection Pooler (RECOMMENDED)
|
|
|
|
Supabase provides a connection pooler that's more reliable:
|
|
|
|
1. **Go to Supabase Dashboard** → Settings → Database
|
|
2. **Find "Connection Pooling" section**
|
|
3. **Select "Transaction" mode** (or "Session" if you need transactions)
|
|
4. **Copy the connection string** - it will look like:
|
|
```
|
|
postgresql://postgres:[YOUR-PASSWORD]@mycttyevrycmkhlvwgfk.pooler.supabase.com:6543/postgres
|
|
```
|
|
OR
|
|
```
|
|
postgresql://postgres:[YOUR-PASSWORD]@mycttyevrycmkhlvwgfk.pooler.supabase.com:5432/postgres
|
|
```
|
|
|
|
5. **Update your `.env` file:**
|
|
```env
|
|
DATABASE_URL=postgresql://postgres:your_password@mycttyevrycmkhlvwgfk.pooler.supabase.com:6543/postgres
|
|
```
|
|
|
|
**Key differences:**
|
|
- Uses `.pooler.supabase.com` instead of `db.xxx.supabase.co`
|
|
- Port is usually `6543` (transaction mode) or `5432` (session mode)
|
|
- More reliable for serverless/cloud deployments
|
|
|
|
## Solution 2: Check Project Status
|
|
|
|
1. Go to Supabase Dashboard
|
|
2. Check if your project shows as "Paused" or "Inactive"
|
|
3. If paused, click "Restore" to reactivate it
|
|
4. Wait a few minutes for DNS to propagate
|
|
5. Try connecting again
|
|
|
|
## Solution 3: Use Supabase Client Instead
|
|
|
|
If direct connection doesn't work, use Supabase client:
|
|
|
|
1. **Get your API keys:**
|
|
- Go to Supabase Dashboard → Settings → API
|
|
- Copy:
|
|
- **Project URL**: `https://mycttyevrycmkhlvwgfk.supabase.co`
|
|
- **service_role key** (secret)
|
|
|
|
2. **Update your `.env` file:**
|
|
```env
|
|
# 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
|
|
```
|
|
|
|
3. **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 use `db.`)
|
|
|
|
## Quick Test
|
|
|
|
After updating your `.env` file, test the connection:
|
|
|
|
```bash
|
|
cd backend
|
|
npm run dev
|
|
```
|
|
|
|
You should see:
|
|
```
|
|
✅ Database connection successful (PostgreSQL direct)
|
|
```
|
|
|
|
Or:
|
|
```
|
|
✅ Database connection successful (Supabase)
|
|
```
|
|
|
|
## Still Not Working?
|
|
|
|
1. **Check your network/firewall** - Make sure port 5432 or 6543 is not blocked
|
|
2. **Try pinging the hostname:**
|
|
```bash
|
|
ping mycttyevrycmkhlvwgfk.pooler.supabase.com
|
|
```
|
|
3. **Verify project is active** in Supabase Dashboard
|
|
4. **Check Supabase status page** for any outages
|
|
5. **Contact Supabase support** if project appears active but connection fails
|
|
|