PostgreSQL - port 5432 already in use
balt1794
Posted on February 11, 2021
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:
Posted on February 11, 2021
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.