Cannot connect to Postgres server running through brew services

leo.fcx picture leo.fcx · Sep 26, 2016 · Viewed 36k times · Source

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?

Answer

Wilson Silva picture Wilson Silva · Jan 23, 2017

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

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