Skip to content

Latest commit

 

History

History
118 lines (82 loc) · 2.69 KB

File metadata and controls

118 lines (82 loc) · 2.69 KB

Quick Setup & Troubleshooting

✅ What You've Already Done

Your .env.local has a Neon PostgreSQL database configured:

DATABASE_URL=postgresql://neondb_owner:npg_***@ep-quiet-frost-***-pooler.us-east-1.aws.neon.tech/neondb?sslmode=require&channel_binding=require

This is excellent for deployment! 🎉


❌ Why Connection is Timing Out

The database is in us-east-1 AWS region but your connection is being blocked. Possible causes:

  1. Neon project not active - Check Neon dashboard
  2. Network/Firewall blocking - Neon has IP whitelist
  3. SSL/TLS issues - Neon requires SSL
  4. Service not running - Restart Neon compute

🔧 How to Fix

Step 1: Verify Neon Database is Active

  1. Go to https://console.neon.tech
  2. Check your project status
  3. Make sure database is Active (green status)

Step 2: Test Connection

# Test with psql
psql "postgresql://neondb_owner:npg_a9FErQ7ImPid@ep-***-pooler.us-east-1.aws.neon.tech/neondb?sslmode=require"

# Or with Node.js
node -e "
const { Pool } = require('pg');
const pool = new Pool({ connectionString: process.env.DATABASE_URL });
pool.query('SELECT NOW()', (err, res) => {
  if (err) console.error('Error:', err.message);
  else console.log('Connected:', res.rows[0]);
  process.exit();
});
"

Step 3: Check IP Whitelist (if needed)

  1. Neon Dashboard → Project Settings
  2. IP Whitelist → Add your IP or allow all (0.0.0.0/0)

Step 4: For Local Testing (Temporary)

Use local PostgreSQL instead:

# .env.local
DATABASE_URL="postgresql://postgres:ayush@2004@localhost:5432/k8s"

Then restart: npm run dev


🚀 For Production Deployment

Your Neon setup is already production-ready! Just:

  1. Vercel → Add .env.local to project settings
  2. Railway → Existing DATABASE_URL will work
  3. Docker → Pass DATABASE_URL as environment variable
# Docker example
docker run -e DATABASE_URL="postgresql://..." my-app

📝 Next Steps to Get Running

Option A: Use Local PostgreSQL

# Install and start PostgreSQL
brew services start postgresql  # macOS
sudo systemctl start postgresql  # Linux

# Create database
createdb k8s

# Update .env.local
DATABASE_URL="postgresql://postgres:ayush@2004@localhost:5432/k8s"

# Start app
npm run dev

Option B: Fix Neon Connection

  1. Login to Neon console
  2. Verify database is active
  3. Check IP whitelist settings
  4. Restart your app: npm run dev

✨ Your App is Ready to Deploy!

Once database works, you can deploy to:

  • Vercel (easiest for Next.js)
  • Railway
  • Docker/Kubernetes
  • AWS, Google Cloud, etc.

All you need is to set the DATABASE_URL env variable!