I\'m using http://postgresapp.com. In the menubar it gives the error \" Could not start on port 5432.\" Similarly if I try to start the server from the terminal, I get:
You my have another instance of postgres running, that is the only application interested in this port. You should use netstat and ps to determine this. Then stop the instance and uninstall it, you mayhave installed enterpiseDb for example, that is what I did.
A file named "postmaster.pid" (in my $PGDATA directory) were preventing postgresql to start. It was a zombie file, placed there 10 days ago and when I brutally shut down the computer (pulling the plug, literally), no clean up process had the opportunity to remove that file.
This is what worked for me: $ sudo pkill -u postgres
Props to this resource: https://github.com/PostgresApp/PostgresApp/issues/197#issuecomment-474534056
When trying to open the Postgres app was getting that same error regarding post 5432 (on Mac OSX 10.10.5)
I did:
$ lsof -i | grep LISTEN
Saw which PID was running postgres at that port, did:
$ killall {pid}
and then $ brew uninstall postgres
After that, restarted my Mac, and ran:
$ lsof -i | grep LISTEN
again just to make sure. Saw no postgres running anywhere and was able to open the Postgres app without getting that warning.
Then I reinstalled postgres with $ brew install postgres
ANOTHER OPTION:
(I also tried this one time when the above approach didn't work and I could not kill any of the PID)
$ ps auxw | grep post
Saw a slew postgres processes, which I then sudo kill <PID>
Everything working fine now.
I generally face this issue on my mac, and this fixes it for me always
rm /usr/local/var/postgres/postmaster.pid
brew services restart postgresql
Hope this is helpful
You can stop the process by finding the PID with
lsof -i :5432
and then killing it with
kill -9 <PID>