Postgresql – Cannot connect to Postgres server running through brew services

homebrewmacospostgresql

I've been looking for a solution for this and could not find a working solution.

I've installed postgres using brew (brew install postgres) in my MacBook and I am currently running it using brew services (brew services list displays postgres as a running service). However, when I try to run psql I get following error.

psql: 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"?

Anyone has already solved similar problem?

Best Answer

I had the same error and I fixed it by removing the process pid file:

rm -f /usr/local/var/postgres/postmaster.pid

Related Topic