Common issues and solutions for the NestJS API Starter Kit.
Problem: The application can't connect to PostgreSQL because the user doesn't exist.
Cause: Mismatch between your .env file credentials and the PostgreSQL
container setup.
Solutions:
# Stop and remove the existing PostgreSQL container and volume
docker compose down postgres
docker volume rm nestjs-api-starter-kit_postgres_data # or your project name
# Start PostgreSQL again (it will recreate with correct credentials)
docker compose up -d postgres
# Wait for PostgreSQL to be ready, then run migrations
sleep 10
npm run typeorm:migration:run # or your package manager# Stop all services and remove volumes
docker compose down -v
# Start services again
docker compose up -d postgres
# Run migrations
npm run typeorm:migration:run # or your package manager# Connect to the PostgreSQL container
docker compose exec postgres psql -U postgres
# Create user and database manually
CREATE USER nestjs_user WITH PASSWORD 'nestjs_password';
CREATE DATABASE nestjs_starter OWNER nestjs_user;
GRANT ALL PRIVILEGES ON DATABASE nestjs_starter TO nestjs_user;
\qProblem: Can't connect to PostgreSQL at all.
Solutions:
-
Check if PostgreSQL is running:
docker compose ps postgres # Should show "Up" status -
Check PostgreSQL logs:
docker compose logs postgres # Look for any error messages -
Restart PostgreSQL:
docker compose restart postgres sleep 10 # Wait for startup -
Check if port 5432 is available:
lsof -i :5432 # Kill any process using port 5432 if needed
Problem: Wrong password in your configuration.
Solution:
-
Check your
.envfile has the correct password:cat .env | grep DB_PASSWORD # Should show: DB_PASSWORD=nestjs_password
-
If it's different, update it:
# Edit .env file DB_PASSWORD=nestjs_password # Restart your application npm run start:dev # or your package manager
Solutions:
# Find process using port 3000
lsof -ti:3000
# Kill the process
kill -9 $(lsof -ti:3000)
# Or use a different port
PORT=3001 npm run start:devSolutions:
# Clear dependencies and reinstall
rm -rf node_modules
rm package-lock.json yarn.lock pnpm-lock.yaml bun.lockb # Remove all lock files
npm install # or your preferred package manager
# Clear build cache
rm -rf dist
npm run buildSolutions:
# Check TypeScript version
npm list typescript
# Rebuild
npm run build
# If errors persist, check tsconfig.jsonProblem: Docker is not running.
Solution: Start Docker Desktop or Docker service.
Solutions:
# Stop containers using the port
docker compose down
# Remove all containers (if needed)
docker container prune
# Check what's using the port
docker ps -aSolutions:
# On Windows/macOS: Check Docker Desktop file sharing settings
# On Linux: Check file permissions
# Reset volumes
docker compose down -v
docker compose upSolution:
# Install Bun
curl -fsSL https://bun.sh/install | bash
source ~/.bashrc # or restart terminalSolution:
# Install pnpm
npm install -g pnpm
# or
curl -fsSL https://get.pnpm.io/install.sh | sh -Solution:
# Choose one package manager and remove other lock files
rm package-lock.json yarn.lock pnpm-lock.yaml bun.lockb # Remove all
npm install # Then install with your chosen package managerSolutions:
-
Check file watching limits (Linux):
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf sudo sysctl -p
-
Restart development server:
# Stop with Ctrl+C, then restart npm run start:dev
Solutions:
- Check .env file location: Must be in project root
- Check .env file syntax: No spaces around
= - Restart application after changing .env
- Check if .env is in .gitignore (it should be)
Solution:
# Make sure test database is configured differently
# Check test/.env or use separate test database
DB_NAME=nestjs_starter_test npm run test:e2eSolution:
# Increase Node.js memory
NODE_OPTIONS="--max-old-space-size=4096" npm testIf these solutions don't work:
- Check logs carefully for specific error messages
- Search existing issues in the repository
- Create a new issue with:
- Your operating system
- Node.js version (
node --version) - Package manager and version
- Complete error message
- Steps to reproduce
# Check versions
node --version
npm --version # or bun --version, pnpm --version, yarn --version
docker --version
docker compose version
# Check service status
docker compose ps
# Check logs
docker compose logs postgres
docker compose logs api
# Check environment
cat .env | grep DB_
# Test database connection
docker compose exec postgres psql -U nestjs_user -d nestjs_starter -c "SELECT version();"
# Check API health
curl http://localhost:3000/health/liveIf everything is broken:
# Stop everything
docker compose down -v
# Clean Docker
docker system prune -a
# Clean Node
rm -rf node_modules
rm package-lock.json yarn.lock pnpm-lock.yaml bun.lockb
# Fresh start
cp .env.example .env
npm install
docker compose up -d postgres
sleep 10
npm run typeorm:migration:run
npm run start:dev