Skip to main content

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:

  1. You can kill the server if it is already started:
    1. Find PID of psql using postgres -D /usr/local/var/postgres
    2. You should see following output:

      FATAL: lock file "postmanter.pid" already exists HINT: Is another postmaster (PID <PID_NUMBER>) running in data...

    3. 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>
    4. Restart your PC
  2. 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.
  3. Check brew services:
    1. Run this command to see active servers via brew
    2. brew services list It will show you all servers with status.
    3. If Postgres is active turn off using: brew services stop postgresql
    4. Or you may just turn off all servers with: brew services stop --all
    5. Restart your laptop (optional)