Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 312
Petran Avatar asked Feb 23 '17 13:02

Petran


People also ask

How do I know which port postgres is running?

On Windows you can use Control Panel -> Administrative Tools -> Services and restart the PostgreSQL service. For ]po[, the PostgreSQL service is called "]po[ PostgreSQL". Repeating the "Check for Port IP" step above, you should now see that the port IP is "0.0.

Is postgres running on port 5432?

The PostgreSQL database service is available on localhost and the default PostgreSQL port is 5432 .

What application uses port 5432?

TCP port 5432 is used by the PostgreSQL Database Server, an object-relational database management system (RDBMS) server developed by PostgreSQL Global Development Group.


3 Answers

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
like image 100
josephmisiti Avatar answered Oct 10 '22 18:10

josephmisiti


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.

like image 31
clemens Avatar answered Oct 10 '22 18:10

clemens


Askubuntu provided an answer that worked for me:

sudo pkill -u postgres

Source: Nicely stop all postgres processes

like image 31
tread Avatar answered Oct 10 '22 18:10

tread