DevOps
Stop Local Windows PostgreSQL and Run Docker Postgres on Port 5433
Published
Aug 11, 2026
Reading Time
8 min read
Admin
Author
Fix the Windows PostgreSQL vs Docker port clash: stop the local service, map Docker to 5433, update DATABASE_URL, and verify the connection.
Why this matters
On Windows, a local PostgreSQL service often binds to 5432. If Docker Compose also tries to publish 5432:5432, one of them fails or your app connects to the wrong database.
Two clean options:
- Option A — Stop Windows Postgres, let Docker use
5432 - Option B — Keep Windows Postgres running, map Docker to
5433(recommended when you need both)
This guide focuses on Option B, with the commands to stop the Windows service when you want Option A.
1. Stop local Windows PostgreSQL (Admin PowerShell)
Open PowerShell as Administrator, then check and stop the service.
Status check
Get-Service -Name "*postgres*"
Stop the service
Stop-Service -Name "postgresql-x64-18" -Force
Replace postgresql-x64-18 with the exact name from Get-Service if your version differs.
Optional: disable auto-start
Set-Service -Name "postgresql-x64-18" -StartupType Disabled
Confirm
Get-Service -Name "postgresql-x64-18"
If you are not running as Admin, these commands will fail. Use the Docker 5433 approach below instead.
2. Run Docker Postgres on port 5433
cd path\\to\\your\\backend
$env:DEPLOY_TAG = "local"
docker compose --profile local up -d --force-recreate postgres
Compose should publish:
ports:
- "5433:5432"
3. Point .env at Docker
DATABASE_URL=postgresql://user:password@localhost:5433/your_database
4. Verify
docker ps --filter name=postgres --format "{{.Names}} {{.Ports}} {{.Status}}"
Expected: 0.0.0.0:5433->5432/tcp.
node -e "require('dotenv').config(); const {Client}=require('pg'); const c=new Client({connectionString:process.env.DATABASE_URL}); c.connect().then(()=>c.query('select current_user, current_database()')).then(r=>{console.log(r.rows); return c.end()})"
5. Start the backend
pnpm run dev
Quick comparison
- Option A — Windows Postgres off + Docker
5432+.env5432 - Option B — Windows Postgres on + Docker
5433+.env5433
#docker#postgresql#windows#devops
Share:

Comments
0Login to post a comment.
Sign inLoading comments…