Fixing issue when PostgreSQL didn't stop correctly
Actual problem text: 'Is the server running on host "localhost" (::1) and accepting TCP/IP connections on port 5432?'
This problem says that we somehow didn't stop the SQL server and it can't run again because of the unfinished shutdown.
May happen when:
- We shutdown laptop with running servers
- If you faced another option please add it here.
Solutions:
- You can kill the server if it is already started:
- Find PID of psql using
postgres -D /usr/local/var/postgres - You should see following output:
FATAL: lock file "postmanter.pid" already exists HINT: Is another postmaster (PID <PID_NUMBER>) running in data...
- We don't care about the whole message, if you see PID_NUMBER, run the following command to shut down the running psql servers:
kill -9 <PID_NUMBER> - Restart your PC
- Find PID of psql using
- You can just shut down the laptop and run it again, but if you have a Warning message box after the laptop is turned on, the problem still exists.
- Check brew services:
- Run this command to see active servers via brew
brew services listIt will show you all servers with status.- If Postgres is active turn off using:
brew services stop postgresql - Or you may just turn off all servers with:
brew services stop --all - Restart your laptop (optional)