Your app is trying to connect to a Neon PostgreSQL database but getting ETIMEDOUT errors.
Check if your .env.local has a DATABASE_URL:
cat .env.localYou should see something like:
DATABASE_URL=postgresql://user:password@host/database?sslmode=require
# Install PostgreSQL
brew install postgresql # macOS
sudo apt install postgresql # Ubuntu
# Download installer for Windows
# Start PostgreSQL
brew services start postgresql # macOS
sudo systemctl start postgresql # Ubuntu
# Create database
createdb k8s
# Update .env.local
echo 'DATABASE_URL=postgresql://postgres@localhost:5432/k8s' > .env.local
# Restart app
npm run dev✅ This works immediately!
Your .env.local already has Neon configured. Try these fixes:
Check 1: Is the database active?
- Visit https://console.neon.tech
- Look for green "Active" status
- If red, click to activate it
Check 2: Add IP to whitelist
# See your current IP
curl https://api.ipify.org
# Then in Neon Dashboard:
# Settings → IP Whitelist → Add IP
# Or allow all: 0.0.0.0/0Check 3: Test the connection string
# Copy your DATABASE_URL from .env.local
DATABASE_URL="postgresql://..." npm run devIf Neon isn't working, try free alternatives:
Railway.app (Very Easy)
# 1. Push to GitHub
git push origin main
# 2. Sign up at https://railway.app
# 3. Connect your GitHub repo
# 4. Create PostgreSQL plugin (automatic DATABASE_URL)
# 5. Deploy!Heroku + Postgres (Also Easy)
# 1. Install Heroku CLI
# 2. heroku login
# 3. heroku create my-app
# 4. heroku addons:create heroku-postgresql:hobby-dev
# 5. git push heroku main# Create a test file
cat > test-db.js << 'EOF'
const { Pool } = require('pg');
const pool = new Pool({ connectionString: process.env.DATABASE_URL });
pool.query('SELECT NOW()', (err, res) => {
if (err) {
console.error('❌ Connection failed:', err.message);
} else {
console.log('✅ Connected! Current time:', res.rows[0].now);
}
process.exit();
});
EOF
# Run the test
DATABASE_URL="YOUR_CONNECTION_STRING" node test-db.jsFor development:
- Use local PostgreSQL
- Set:
DATABASE_URL=postgresql://postgres@localhost:5432/k8s
For production/deployment:
- Use Neon, Railway, or AWS RDS
- Set DATABASE_URL in your hosting provider's environment variables
-
Check PostgreSQL is running
psql -U postgres -c "SELECT 1" -
Check your connection string format
postgresql://username:password@host:port/database -
Check firewall/network
ping your-database-host.com
-
Check with verbose logs
DEBUG=* npm run dev
Need help? Check these:
- PostgreSQL docs: https://www.postgresql.org/docs/
- Neon docs: https://neon.tech/docs
- Railway docs: https://docs.railway.app