← Back to Dashboard

🔧 Database Troubleshooting

Fix database connection issues across all devices

🚀 Quick Database Test

Test your database connection right now:

🔑 Environment Variables Setup

⚠️ Important: Each device needs its own environment variables configured!

1. Create .env file on each device:

# Database Configuration DATABASE_URL=postgresql://username:password@host:port/database NETLIFY_DATABASE_URL=postgresql://username:password@host:port/database NETLIFY_DATABASE_URL_UNPOOLED=postgresql://username:password@host:port/database SUPABASE_DATABASE_URL=postgresql://username:password@host:port/database # JWT Secret JWT_SECRET=your_jwt_secret_here # Email Configuration RESEND_API_KEY=your_resend_api_key_here # Stripe Configuration STRIPE_SECRET_KEY=your_stripe_secret_key_here STRIPE_WEBHOOK_SECRET=your_stripe_webhook_secret_here

2. For Neon Database (Recommended):

Get your Neon connection string:

  1. Go to Neon Console
  2. Select your project
  3. Go to "Connection Details"
  4. Copy the "Connection string" (not the pooled one)
  5. Use it as your DATABASE_URL

3. For Supabase Database:

Get your Supabase connection string:

  1. Go to Supabase Dashboard
  2. Select your project
  3. Go to Settings → Database
  4. Copy the "Connection string" under "Connection pooling"
  5. Use it as your DATABASE_URL

📱 Device-Specific Setup

Windows:

Create .env file in project root:

# In your project folder (C:\Users\vince\OneDrive\Desktop\SellSite\) # Create a file named ".env" (no extension) # Add your database URL and other variables

Mac/Linux:

Create .env file in project root:

# In your project folder touch .env echo "DATABASE_URL=your_database_url_here" >> .env

Mobile/Tablet:

Use environment variable apps:

  • iOS: Use "Env" or "Environment Variables" app
  • Android: Use "Environment Variables" or "Termux"
  • Alternative: Use a cloud-based config service

🔍 Common Issues & Solutions

Issue 1: "Database not connected"

Solution:

  • Check if .env file exists in project root
  • Verify DATABASE_URL is correct
  • Ensure database server is running
  • Check network connectivity

Issue 2: "Connection timeout"

Solution:

  • Check firewall settings
  • Verify database server allows external connections
  • Try using pooled connection string
  • Check if database is in same region

Issue 3: "Authentication failed"

Solution:

  • Verify username and password
  • Check if database user has proper permissions
  • Ensure connection string format is correct
  • Try resetting database password

Issue 4: "Table doesn't exist"

Solution:

  • Run database migration scripts
  • Check if tables were created properly
  • Verify database schema
  • Re-run initialization scripts

🌐 Network Configuration

Firewall Settings:

Allow database connections:

  • Windows: Allow PostgreSQL (port 5432) in Windows Firewall
  • Mac: Allow connections in System Preferences → Security
  • Linux: Configure iptables or ufw
  • Router: Port forward 5432 if needed

Cloud Database Settings:

Configure database for external access:

  • Neon: Enable "Allow connections from anywhere"
  • Supabase: Check "Allow connections from anywhere"
  • AWS RDS: Configure security groups
  • Google Cloud: Configure firewall rules

🛠️ Testing Tools

Database Connection Test:

Test your connection string:

# Using psql (PostgreSQL client) psql "postgresql://username:password@host:port/database" # Using Node.js node -e " const { neon } = require('@neondatabase/serverless'); const sql = neon(process.env.DATABASE_URL); sql\`SELECT NOW()\`.then(console.log).catch(console.error); "

Network Connectivity Test:

Test if you can reach the database server:

# Test connection to database host ping your-database-host.com telnet your-database-host.com 5432

🚨 Emergency Fixes

Quick Database Reset:

If nothing else works:

  1. Create a new database instance
  2. Update your DATABASE_URL
  3. Run the initialization scripts
  4. Test the connection

Fallback Configuration:

Use local database as backup:

# Install PostgreSQL locally # Use local connection string DATABASE_URL=postgresql://localhost:5432/sellsite_local