Error: database files are incompatible with server. The data directory was initialized by PostgreSQL version 15, which is not compatible with this version 14.9
Root Cause: The PostgreSQL data volume was created with a different version than what's specified in the docker-compose.yml file.
# Stop all running containers
docker-compose down
# Remove all containers, networks, and volumes
docker-compose down -v# Remove unused Docker resources
docker system prune -f
# Remove all volumes (be careful - this removes ALL volumes)
docker volume prune -f# Start all services fresh
docker-compose up --buildIf you want to preserve existing data, you can:
The docker-compose.yml has been updated to use postgis/postgis:15-3.4 which should be compatible.
# 1. Start with PostgreSQL 15
docker-compose up postgres
# 2. Create backup of existing data (if any)
docker-compose exec postgres pg_dump -U lsdn_user lsdn_db > backup.sql
# 3. Stop and remove old volume
docker-compose down -v
# 4. Start fresh
docker-compose up --build
# 5. Restore data
docker-compose exec postgres psql -U lsdn_user -d lsdn_db < backup.sqlWarning: WARNING Memory overcommit must be enabled!
This is just a warning and won't prevent Redis from working, but you can fix it:
# Enable memory overcommit
sudo sysctl vm.overcommit_memory=1
# Make it permanent
echo 'vm.overcommit_memory = 1' | sudo tee -a /etc/sysctl.confAdd this to the Redis service in docker-compose.yml:
redis:
image: redis:7-alpine
sysctls:
- net.core.somaxconn=1000
# ... rest of configCreate a script to completely reset your Docker environment:
#!/bin/bash
# reset-docker.sh
echo "Stopping all containers..."
docker-compose down
echo "Removing all volumes..."
docker-compose down -v
echo "Removing unused Docker resources..."
docker system prune -f
echo "Starting fresh..."
docker-compose up --build
echo "Done! Your application should now be running."
echo "Frontend: http://localhost:5173"
echo "Backend: http://localhost:3000"Make it executable and run:
chmod +x reset-docker.sh
./reset-docker.shAfter fixing the issue:
-
Check all services are running:
docker-compose ps
-
Check PostgreSQL health:
docker-compose logs postgres
-
Test database connection:
docker-compose exec postgres pg_isready -U lsdn_user -
Run migrations:
docker-compose exec backend node dist/scripts/migrate.js -
Access applications:
- Frontend: http://localhost:5173
- Backend health check: http://localhost:3000/health
To avoid this issue in the future:
- Always use the same PostgreSQL version in your docker-compose.yml
- Document your database schema changes in migrations
- Use consistent image tags (avoid
latesttags) - Backup important data before making changes
If you continue to have issues:
- Check Docker logs:
docker-compose logs - Verify Docker is running:
docker ps - Check available disk space:
df -h - Ensure ports 5432, 6379, 3000, 5173 are available