Adjust the version number in service names if you installed PostgreSQL 16 or 17 instead of 18. Run
sc query type= all | findstr postgresql to find your exact service name.Check status
Check if the PostgreSQL service is running
C:\> sc query postgresql-x64-18
STATE : 4 RUNNING
PS> Get-Service postgresql-x64-18 | Select Status,Name
Running postgresql-x64-18
Start / stop / restart
Manage the service from the command line
C:\> net start postgresql-x64-18
The postgresql-x64-18 service was started successfully.
C:\> net stop postgresql-x64-18
The postgresql-x64-18 service was stopped successfully.
You can also use Services (Win+R → services.msc): find postgresql-x64-18 and right-click for Start, Stop or Restart.
Startup type
Configure automatic startup on boot
# Automatic (default — starts with Windows):
C:\> sc config postgresql-x64-18 start= auto
# Manual (start on demand only):
C:\> sc config postgresql-x64-18 start= demand
Note the space after
start= — required syntax for the sc command.Recovery
Restart automatically on failure
C:\> sc failure postgresql-x64-18 reset= 86400 actions= restart/5000/restart/10000/restart/30000
# Restarts after 5s, 10s, 30s on consecutive failures
Or configure visually: services.msc → double-click the service → Recovery tab → set all failure actions to Restart the Service.
Log files
Find PostgreSQL logs on Windows
# Default log directory:
C:\Program Files\PostgreSQL\18\data\log\
# Open in Explorer:
C:\> explorer "C:\Program Files\PostgreSQL\18\data\log"
# Tail latest log (PowerShell):
PS> Get-Content "C:\Program Files\PostgreSQL\18\data\log\postgresql*.log" -Tail 50
FAQ
Windows service questions
PostgreSQL service not starting
Check Windows Event Viewer (eventvwr.msc) under Windows Logs → Application. Also check PostgreSQL log files in the data/log folder. Common causes: port 5432 already in use, data directory permissions, or corrupted cluster. See Service not starting guide.
What account does the service run under?
By default the EDB installer uses the built-in NetworkService account. For production you may want a dedicated low-privilege service account with access only to the data directory.
How do I find the data directory path?
Run:
psql -U postgres -c "SHOW data_directory;". Or check the service binary path in services.msc — it will include -D path o\data.