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:
This command is a one-liner that instantly kills all PostgresSQL processes.
sudo kill -kill $(sudo lsof -t -i :5432)
This fixed all my problems on Mac OSX Mojave 10.14.1.
It can also happen that the PID is taken. This ocurred to me when the Computer suffered an unexpected reboot.
If so, you must go to:
˜/Library/Application Support/Postgres/var-9.4
You can check that path in Postgres.app Preferences dialog.
And then, just remove the pid file
sudo rm postmaster.pid
And the server starts up right away.
You most likely has a PostgreSQL installed, deleted it and installed it again. PostgreSQL typically used port 5432 but if not available, increases to the next available one, in this case 5433. So, you probably chose this port on your second install.
I think you should check file:
/etc/services
and adjust rows below for your expected port number:
postgresql 5432/udp # PostgreSQL Database
postgresql 5432/tcp # PostgreSQL Database
After this you should restart your computer (simplest way).
I was just having this exact issue. When I ran which psql
it was pointing at the Postgres client tools installed with Lion:
/usr/bin/psql
Using a hint from Frank Wiles I ran ps auxw | grep post
to confirm that postgres was running and that it was running on the right port, that also showed me the postgres.app path:
/Applications/Postgres.app/Contents/MacOS/bin/postgres
.
So I edited by .bash_profile to export that directory. On first effort I added it to the end of the path. When I ran echo $PATH
I could see that usr/bin was the first thing in the path, and which psql
still gave the /usr/bin
path. At that point a friend guided me in the right direction:
export PATH="/Applications/Postgres.app/Contents/MacOS/bin:${PATH}"
Start a new terminal window, then run which psql
-- it should point to the postgres.app location and psql should fire up the postgres shell. Works fine now.
I had a similar problem where I could not connect to the Postgres.app even though the app itself said that it is running on port 5432.
I am not sure why, but even when I quit the app and checked that no postgres processes was running with ps -a. these files existed:
/tmp/.s.PGSQL.5432
and
/tmp/.s.PGSQL.5432.lock
My solution was to delete these files and then start the postgres.app again.
I had similar problem when trying to use postgresql with rails. Updating my Gemfile to use new version of gem pg solve this problem for me. (gem pg version 0.16.0 works). In the Gemfile use:
gem 'pg', '0.16.0'
then run the following to update the gem
bundle install --without production
bundle update
bundle install