Petran
Petran

Reputation: 8087

Postgres.app port in use

I am trying to start the server and getting an error

Port 5432 is already in use

I have brew uninstall postgress

which postgres

gives me nothing.

Activity monitor has 14 postgres processes which I cannot kill. Force quit kill the process and restarts it with another pid. The same with sudo kill -9 PID it kills the process and restarts it with another PID.

Upvotes: 12

Views: 29097

Answers (7)

tread
tread

Reputation: 11108

Askubuntu provided an answer that worked:

sudo pkill -u postgres

Source: Nicely stop all postgres processes

Upvotes: 18

Mana Sh
Mana Sh

Reputation: 1

Use this:

brew services stop postgresql

Good luck!

Upvotes: -1

Suraj Malgave
Suraj Malgave

Reputation: 173

Run those commands

  • To check what is running on port 5432 - $ sudo lsof -i :5432
  • To kill Postgres - $ sudo pkill -u postgres

Upvotes: 0

Sarabjeet Singh
Sarabjeet Singh

Reputation: 117

You can get the list of ports using:

sudo launchctl list

Then enter the application name, and using this command to get the port nunber:

sudo launchctl list | fgrep postg

In my case, the port is 83. Now use:

kill 83

then

sudo kill 5432

Upvotes: 3

josephmisiti
josephmisiti

Reputation: 9974

If you are running into this problem on OSX, do the following:

  1. Find out what is running on that port:
    $ lsof -n -i4TCP:5432

    COMMAND     PID         USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
    python2.7 28687 afdasdfasd    3u  IPv4 0x2f18e1284963d3e3      0t0  TCP 127.0.0.1:54970->127.0.0.1:postgresql (CLOSE_WAIT)
  1. Kill it
    $ kill -9 28687
  1. Restart postgresapp

Upvotes: 28

Roger Camps
Roger Camps

Reputation: 149

$ brew services stop postgresql

This will kill all processes and let you start the server.

Upvotes: 12

clemens
clemens

Reputation: 17722

Have you checked for a launch daemon? It controls the Postgres process when Postgres is installed with Homebrew, and it automatically restarts Postgres after it is killed. Try

sudo launchctl list

or

sudo launchctl list | fgrep postg

to find the name of the daemon. You can stop the daemon with sudo launchctl stop <name> where name depends on the result of the first command.

Upvotes: 23

Related Questions