5

When installing Postgresql 11 I got an error. I did the lesson right. Searched Google but didn’t find. I'm not trying to run different versions of postgresql, I'm just trying to install it.

Error message: Port 5432 is already in use

2
  • You’re on the wrong site. Stackoverflow is for programming questions. superuser.com is for basic software questions.
    – anothermh
    Jan 8, 2019 at 4:43
  • @Mike can you check my answer and see if this can resolve this issue?
    – Arefe
    Jul 25, 2021 at 10:32

6 Answers 6

16
$ sudo lsof -i :5432
$ sudo pkill -u postgres

This is what fixed it for me, the lsof -i :5432 didn't show me anything, but after running the second command, I could finally use port 5432.

1

The error is already evident in the screenshot. Postgres by default runs on post 5432 unless you configure it otherwise.

Go to your terminal and type in pg_ctl stop to stop postgres and try again.

You can also type ps aux|grep postgres and see what processes are currently using postgres.

0

The OS X creates a user name PostgreSQL by default and that creates this issue. You will need to delete this user as you will never need to log in as the user and you should get the port 5432 free to use.

0

I had a similar problem, but the user was me instead postgresql lsof output

Solved as follows:

brew uninstall postgresql

Then from Monitoring system(MacOS Basic util):

turn off all process by postgresql enter image description here

0

In case the Postgres keeps restarting in the background each time you kill it

What's happened is you've setup a background service on your OS that'll keep running every time you kill it.

For me, I accidentally set this up after I installed Postgres via brew. When it's installed, brew gives you the option to run it as a background service.

then you can try these commands

brew services list 

launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist 
-2

Usually this means that there is already a PostgreSQL server running on your Mac.

1
  • The error is already evident in the screenshot. Postgres by default runs on post 5432 unless you configure it otherwise.
    – Mr. Rene
    Dec 18, 2019 at 14:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.