PostgreSQL - port 5432 already in use

balt1794

balt1794

Posted on February 11, 2021

PostgreSQL - port 5432 already in use

New videos very Sunday and Friday.

For more content, visit:

baltlogs

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.

Screen-Shot-2021-02-10-at-1.29.28-PM

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


Enter fullscreen mode Exit fullscreen mode

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.

Screen-Shot-2021-02-11-at-11.07.33-AM

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


Enter fullscreen mode Exit fullscreen mode

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:

Django 3…2…1…Takeoff! Kindle

Django 3…2…1…Takeoff! Paperback

💖 💪 🙅 🚩
balt1794
balt1794

Posted on February 11, 2021

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related