The postgresql-x64-9.6 service on local computer started and then stopped. Some services stop automatically if they are not in use
Solution 1
I had this same issue. and i followed @Craig Ringer's advice. when i check the event viewer i got this error.2018-06-18 12:34:11.222 GMT [4200] FATAL: lock file "postmaster.pid" already exists
2018-06-18 12:34:11.222 GMT [4200] HINT: Is another postmaster (PID 6172) running in data directory "C:/Program Files/PostgreSQL/10/data"?
so i deleted the "postmaster.pid" file in my postgreSQL data directory, start the service again and this time around, the service started properly.
This error might be due to incomplete shutdown of the postgreSQL service.
Solution 2
For some reasons postgresql process is still running in the background.
You can encounter this problem if your system forcefully shutdowns down. Solution:
Windows + X (Open task Manager - Processes)
Find all running postgresql services and 'End Task'.
After all processes have ended. You can reopen task manager to ensure no postgres services is running.
- Restart Postgresql server
Solution 3
I've solved same issue.
Here I have done.
I deleted two files and then restart service. Please these files:postmaster.opts
, postmaster.pid
in "C:/Program Files/PostgreSQL/10/data" directory.
As you seen @Abodesegun Ezekiel's answer, I deleted one more file called "postmaster.opts"
and it worked for me.
Hope it will be helpful.
Solution 4
I have an additional answer to the ones here as to why the somewhat misleading error message can occur, which is now a newer version, 12.2 vs 9.6, ("The postgresql-x64-12 - PostgreSQL 12 Server service on Local Computer started and then stopped. Some services stop automatically if they are not in use by other services or programs.)
Apparently, errors in the pg_hba.conf file will cause the error message above to appear, and the service failed to start.
In my case, I had edited the file and failed to comment out (#) a comment properly. After much Googling, I never saw that mentioned but DID finally remember to double-check my edits, and there the problem was a simple mistake.
I fixed it and the service now starts, no problem.
-Windows 10 x64 Enterprise 1909 18363.752 -PostgreSQL 12.2 (Windows)
Solution 5
My problem was solved by changing the account that runs the service to "Local System" and after that, I was able to start the service.
Related videos on Youtube

user3931984
Updated on July 15, 2022Comments
-
user3931984 10 months
Postgresql service not starting in services.msc. it is showing below message while starting PostgreSQL service in Window server 2008 R2.
" The postgresql-x64-9.6 service on local computer started and then stopped. Some services stop automatically if they are not in use by other services or programs."
-
Craig Ringer almost 6 yearsCheck the PostgreSQL logs and your event viewer logs.
-
user3931984 almost 6 yearsin event viewer log it is showing timed out error message.
-
antiduh almost 6 years@user3931984 - Please ask this question on ServerFault or SuperUser. This is not about a programming problem, so it doesn't belong on SO.
-
Craig Ringer almost 6 yearswith details: exact error messages from event viewer and postgres logs. As text not screenshot so they're searchable.
-
Hamid Shoja about 2 yearsevent log : FATAL: XX000: C:\Program Files\PostgreSQL\13\bin\postgres.exe: could not locate matching postgres executable LOCATION: getInstallationPaths, d:\pginstaller_13.auto\postgres.windows-x64\src\backend\postmaster\postmaster.c:1489 any idea?
-
-
Jorge González Lorenzo over 4 yearsSimilar issue, config error in postgresql.conf. I find the error message a bit misleading.
-
Константин Ван almost 4 yearsEvent Viewer → Windows Logs → Application. My
Error
fromPostgreSQL
sayspostgres: superuser_reserved_connections (3) plus max_wal_senders (10) must be less than max_connections (10)
. Seems I misconfigured themax_connections
. Solved, thanks. -
user1062589 about 3 yearsI had exactly the same problem described in the original post and this worked for me.
-
Leon over 2 yearsAnd delete
postmaster.opts
file in same directory as well. Then restart service. It should be fine with out any error. I hope it will be helpful. :) -
Abdelhakim over 2 yearsSame thing happened to me. I edited pg_hba.conf and later tried to restart the server it wouldn't run anymore. Had to fix pg_hba.conf to make it work again. So +1.
-
Emile ASTIH almost 2 yearsHello, adding on this: make sure there is no PostgreSQL process already running in the background by opening Task Manager and searching for PostgreSQL. If found right click -> End Task.