dwyl / learn-postgresql

🐘 Learn how to use PostgreSQL and Structured Query Language (SQL) to store and query your relational data. 🔍
211 stars 23 forks source link

Port 5432 is already in use ... #60

Open nelsonic opened 5 years ago

nelsonic commented 5 years ago

If when you open the Postgres.app you see the following error message: image Or clicking "start" shows you the message: image

Port 5432 is already in use
Usually this means that there is already a PostgreSQL server running on your Mac.
If you want to run multiple servers simultaneously, use different ports.

Running

lsof -i :5432

As suggested in this SO: https://stackoverflow.com/questions/12028037/postgres-app-could-not-start-on-port-5432 I see that: image

I quit DBeaver and then Postgres.app could connect. 👍

nelsonic commented 5 years ago

This issue is solved for me ... ✅ I'm wondering if it's worth including in a "trouble-shooting" section ... 🤔 or if people can just Google for it and find their answer! 🔍

luqmanoop commented 5 years ago

I think it would be nice to include it (with links) in the "trouble-shooting" section since not everybody knows how to use Google to their advantage. It'll also save people the time of agonising troubleshooting

7astro7 commented 4 years ago

Hi guys, I tried running lsof -i :5432 in the terminal and it didnt produce any output. I got the same message: "Port 5432 is already in use Usually this means that there is already a PostgreSQL server running on your Mac. If you want to run multiple servers simultaneously, use different ports." Any ideas?

mrjoedang commented 4 years ago

@7astro7 try running the command as sudo.

sudo lsof -i :5432

You can kill the process using the PID from the command above: sudo kill -9 PID

arman-zhumakhan commented 4 years ago

That worked for me. $ sudo pkill -u postgres

https://github.com/PostgresApp/PostgresApp/issues/197#issuecomment-474534056

arman-zhumakhan commented 4 years ago

Hi guys, I tried running lsof -i :5432 in the terminal and it didnt produce any output. I got the same message: "Port 5432 is already in use Usually this means that there is already a PostgreSQL server running on your Mac. If you want to run multiple servers simultaneously, use different ports." Any ideas?

Try this $ sudo pkill -u postgres

ayelen3976 commented 3 years ago

Hi, can any help me? . I cant connect me with postgres when I put the commando "psql -U postgres"

Captura de Pantalla 2020-12-26 a la(s) 13 34 10 Captura de Pantalla 2020-12-26 a la(s) 13 36 13 Captura de Pantalla 2020-12-26 a la(s) 13 34 19
hamdiazer8 commented 3 years ago

hi guys is ther any solution for pc because sudo is not working in gitbash nor cmd thankyou

hamdiazer8 commented 3 years ago

you can kill the process in pc with this netstat -aon | findstr '5432'

surajmalgave commented 2 years ago

Run following commands

nelsonic commented 2 years ago

@re-Tick this thread is probably not the best place to ask questions if you need an immediate response. ⏳ What Operating System are you using. How did you install Postgres? 🤷‍♂️

freddy24-7 commented 2 years ago

This worked: https://dev.to/balt1794/postgresql-port-5432-already-in-use-1pcf

senapahlevi commented 2 years ago

hello in my case postgresql Still run after sudo pkill -u postgres so here how i solved these problem first check PID on your terminal sudo lsof -i :5432 in my case using Mac OS so open app activity monitor check process name postgressql and see/check postgressql list PID same as before in the terminal sudo lsof -i :5432, click the postgresql process then forcequit

emelyanenkoig commented 1 year ago

if it can't if the above comments did not help you then open the activity monitor and end all postgres processes

arvish-codal commented 1 year ago

Am a Mac user (Intel Chip and Ventura OS), even if i force quit from the activity monitor, another process of same type are spawned again with new PID's. Please help.

mondalraj commented 1 year ago

Am a Mac user (Intel Chip and Ventura OS), even if i force quit from the activity monitor, another process of same type are spawned again with new PID's. Please help.

I am facing this. same issue, once force qyutting a postgres instance, another instance starts with different PID

blmalone commented 11 months ago

@arvish-codal @mondalraj If you run the follow it should fix your issue 👍

> brew services list # grab the path to the postgres service e.g. ~/Library/LaunchAgents/homebrew.mxcl.postgresql@15.plist
> launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.postgresql@15.plist
> lsof -i :5432 # you should see the service has stopped and you can now try again

What's happened is you've basically 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.

lena-A-Al commented 11 months ago

@freddy24-7 thank you for the link; I was finally able to fix the issue after following the steps. Especially checking activity monitor which is much easier than the terminal.

Adefizzy commented 8 months ago

@blmalone Thank you for the solution. However, when I ran the command

brew services list

I got

postgresql@14 none

and no path was specified for the PostgreSQL@14, so I came up with this path ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist and It worked. so the command I used was launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist

karenprr commented 6 months ago

@blmalone THANK YOU!

claudey commented 5 months ago

@blmalone Thank you for the solution. However, when I ran the command

brew services list

I got

postgresql@14 none

and no path was specified for the PostgreSQL@14, so I came up with this path ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist and It worked. so the command I used was launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist

This worked for me.

brytebee commented 4 months ago

Here's how I solved it.