author avatar

satya

Sat Feb 03 2024

while running psql postgres if we face the below error: psql: error: connection to server on socket "/tmp/.s.PGSQL.5432" failed: No such file or directory That can be because of 2 reasons.

  1. Your service isn't running , that can be fixed using brew services start postgresql@15
  2. Your service is running , but there is some error like
Bootstrap failed: 5: Input/output error
Try re-running the command as root for richer errors.
Error: Failure while executing; `/bin/launchctl bootstrap gui/501 /Users/<user>/Library/LaunchAgents/homebrew.mxcl.postgresql@15.plist` exited with 5.

We can fix the 2nd error by removing the process pid file. • Step 1 -> brew services stop postgresql@15 • Step 2 -> rm -f /opt/homebrew/var/postgresql@15/postmaster.pid (apple sillicon install it at opt/homebrew) • Step 3 -> brew services start postgresql@15 These 3 steps should fix the error and we can check the info by running brew services info postgresql@15