For more content, visit:
When installing your Postgres database for the first time, one of the problems that might arise is that two different versions of the PostgreSQL server are running at the same time. When this happens, you will get a message similar to the screenshot below.
In my case, I downloaded PostgreSQL, but apparently I already had a different version running on my computer and it was using the port 5432. Postgres is known for using port 5432 as a default (this can be changed). The problem described can also be caused by other applications using port 5432.
To check what is running on port 5432, issue the following command on your terminal.
$ sudo lsof -i :5432
When issuing the command above, you will prompted for the computer's password. After entering your password, you should get an output of what's currently running on port 5432.
You might get a different output depending on what application is using the port. In my case, I had a different version of the PostgreSQL server running on my Mac, that was interfering with the Postgres.app. If you have the same problem, to kill all PostgreSQL processes, issue the following command.
$ sudo pkill -u postgres
Usually Postgres is the only app interested in using port 5432, but if after issuing the first command to see what is running on port 5432, you find out that there is an application other than PostgreSQL running on port 5432, try to check the activity monitor and see what app might be interfering with your PostgreSQL server and shut it down from there.
If you find this content useful, please share with others.
Other ways to support:
Top comments (13)
Thanks for this info - nearly 5pm on a Friday for me, what better time to solve a problem :) I can go into the weekend with one less thing to fix.
I'm glad I could help
Thanks!!!
Thanks for the post, it was what I needed!
Awesome! Glad it helped
Thank u so much!!!!!!!!
Thanks for leaving a message. I'm glad the tutorial was helpful :)
I followed these commands and get the following prompt: pkill: Unknown user `postgres'
I know this is late but hopefully it helps someone. -u needs to be followed by the name in the USER column. In your case it would be -u lilimiindahouse. CAUTION this will crash your computer and you will need to restart it. I did that and following the restart everything worked properly. In my situation killing by the PID did not work as the process restarted itself with a different PID immediately. Killing the USER was the only solution.
and still not able to run Postgres can someone plz help!? Thanks
sudo kill -kill $(sudo lsof -t -i :5432)
use this command^^^^^^^^^
sudo kill -kill $(sudo lsof -t -i :5432)
This command saved my life!! ^^^^^