Troubleshooting

PostgreSQL service not starting on Windows — diagnose & fix

PostgreSQL fails to start on Windows for a few common reasons: port conflict, permissions, stale lock file or antivirus interference. This guide covers all of them with exact diagnostic commands.

Start with the quick diagnostics below. Most PostgreSQL startup failures on Windows fall into three categories: port conflict, data directory permissions, or corrupted cluster.

First steps to diagnose the problem

cmd.exe
# 1. Check service status:
C:\> sc query postgresql-x64-18
STATE : 1 STOPPED
# 2. Try to start and capture error:
C:\> net start postgresql-x64-18
System error 1053: The service did not respond to the start or control request
# 3. Check Windows Event Viewer for details:
C:\> eventvwr.msc
# Windows Logs > Application > filter by Source: postgresql

Most common reasons PostgreSQL fails to start

Port 5432 already in use

Another process (possibly another PostgreSQL instance) is using port 5432. Find and stop it:

cmd.exe
C:\> netstat -ano | findstr :5432
TCP 0.0.0.0:5432 0.0.0.0:0 LISTENING 4821
C:\> tasklist | findstr 4821
postgres.exe 4821 ...
C:\> taskkill /PID 4821 /F
Data directory permissions problem

The service account (NetworkService) must have full control of the data directory. Check and fix permissions:

PowerShell — Administrator
PS> icacls "C:\Program Files\PostgreSQL\18\data"
# Should show NetworkService with (F) full control
# Fix permissions if missing:
PS> icacls "C:\Program Files\PostgreSQL\18\data" /grant "NetworkService:(OI)(CI)F"
PostgreSQL log shows "could not create lock file"

A stale postmaster.pid lock file from a previous crash is preventing startup. Delete it carefully:

PowerShell — Administrator
# Only do this when PostgreSQL is definitely stopped:
PS> Remove-Item "C:\Program Files\PostgreSQL\18\data\postmaster.pid"
# Then start the service:
PS> Start-Service postgresql-x64-18
Only delete postmaster.pid when you are certain PostgreSQL is not running. Deleting it while the server is running can corrupt data.
Windows Defender or antivirus blocking PostgreSQL

Windows Defender may block PostgreSQL from binding to its port or accessing data files. Add exclusions for the PostgreSQL binary and data directories: Windows Security → Virus & threat protection → Exclusions → Add an exclusion → Folder → select C:\Program Files\PostgreSQL.

Error: "invalid page in block" or data corruption

This indicates possible data corruption, often from an unclean shutdown (power loss, forced kill). First try: pg_resetwal to reset the write-ahead log (risky — may lose recent transactions). Better: restore from your most recent backup. This is why regular backups with pg_dump are essential.

Check PostgreSQL logs for the actual error

PowerShell
# Find and read latest log file:
PS> Get-ChildItem "C:\Program Files\PostgreSQL\18\data\log" | Sort LastWriteTime -Desc | Select -First 1
PS> Get-Content "C:\Program Files\PostgreSQL\18\data\log\postgresql-2026-06-08.log" -Tail 30
# Look for FATAL or ERROR lines

Related: Port 5432 conflict?

Find and resolve port conflicts step by step.

Port 5432 guide