This Stack Overflow reply was excellent, giving a breakdown of how it was resovled.
Problem
PG::ConnectionBad: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
Running brew services restart postgres looked like it fixed the issue but when looking at brew services an error was present in the output.
Updated 2022-10-11
TLDR;
- Run
brew services list- output
postgresql@14 error
- output
- Run
brew services restart -vvv postgresql@14 - Run
tail -n 10 /opt/homebrew/var/log/[email protected]- output
FATAL: lock file "postmaster.pid" already exists
- output
- Run
rm /opt/homebrew/var/postgresql@14/postmaster.pid - Run
brew services restart -vvv postgresql@14 - Run
brew services list- output
postgresql@14 started
- output