Error: database "lsdn_user" does not exist
Root Cause: The backend was trying to connect to a database named "lsdn_user" instead of "lsdn_db"
Solution: Fixed the DATABASE_URL environment variable in docker-compose.yml:
# Before (incorrect)
- DATABASE_URL=postgresql://${POSTGRES_USER:-lsdn_user}:${POSTGRES_PASSWORD:-lsdn_password}@postgres:5432/${POSTGRES_DB:-lsdn_db}
# After (correct)
- DATABASE_URL=postgresql://lsdn_user:lsdn_password@postgres:5432/lsdn_dbIssue: Frontend and backend both trying to use port 3000
Solution: Updated docker-compose.yml to use different ports:
# Backend
ports:
- "3001:3000" # Changed from "3000:3000"
# Frontend
ports:
- "5173:5173" # Correct port
# Frontend API URL
environment:
- VITE_API_URL=http://backend:3000/api # Changed from localhost:3000- Backend API: http://localhost:3001
- Frontend: http://localhost:5173
- Backend Health Check: http://localhost:3001/health
- PostgreSQL: localhost:5432 (internal: postgres:5432)
- Redis: localhost:6379 (internal: redis:6379)
# Stop all containers
docker-compose down -v
# Clean up Docker system
docker system prune -f
# Start fresh
docker-compose up --build# Check all services are running
docker-compose ps
# Expected output:
# Name Command State Ports
# -----------------------------------------------------------------------------
# lsdn-backend-1 sh -c npm install && npm ... Up 0.0.0.0:3001->3000/tcp
# lsdn-frontend-1 sh -c npm install && npm ... Up 0.0.0.0:5173->5173/tcp
# lsdn-postgres-1 docker-entrypoint.sh postgres Up 0.0.0.0:5432->5432/tcp
# lsdn-redis-1 docker-entrypoint.sh redis ... Up 0.0.0.0:6379->6379/tcp# Build the backend
docker-compose exec backend npm run build
# Run migrations
docker-compose exec backend node dist/scripts/migrate.js
# Optional: Seed with sample data
docker-compose exec backend node dist/scripts/seed.js- Frontend: http://localhost:5173
- Backend Health: http://localhost:3001/health
- API Documentation: http://localhost:3001/api-docs (when implemented)
Solution: Ensure the .env file has correct PostgreSQL credentials:
POSTGRES_DB=lsdn_db
POSTGRES_USER=lsdn_user
POSTGRES_PASSWORD=your_passwordSolution: The frontend should connect to http://backend:3000/api internally, which maps to http://localhost:3001/api externally.
Solution: Ensure all dependencies are installed:
cd backend
npm installSolution: Redis should be accessible at redis:6379 internally and localhost:6379 externally.
docker-compose exec postgres pg_isready -U lsdn_user -d lsdn_db
# Should return: lsdn_db:5432 - accepting connectionsdocker-compose exec redis redis-cli ping
# Should return: PONGcurl http://localhost:3001/health
# Should return: {"status":"ok","timestamp":"...","uptime":...}curl http://localhost:5173
# Should return HTML content- Install Dependencies: Run
npm installin both backend and frontend directories - Configure Environment: Set up .env files with proper values
- Run Migrations: Execute database migrations
- Test Endpoints: Verify API endpoints work correctly
- Frontend Development: Complete React component implementation
- ✅
docker-compose.yml- Fixed port conflicts and database URL - ✅
backend/src/config/database.ts- Fixed environment variables - ✅ All backend service files - Fixed TypeORM and JWT issues
The application should now start without the database connection errors and port conflicts.