Postgres could not connect to server Postgres could not connect to server database database

Postgres could not connect to server


Had a similar problem; a pid file was blocking postgres from starting up. To fix it:

$ rm /usr/local/var/postgres/postmaster.pid$ brew services restart postgresql

and then all is well.


This can sometimes be an issue with a postgres upgrade.

In my case, it happened when upgrading from 9.3 to 9.4.

See http://www.postgresql.org/docs/9.4/static/upgrading.html

OS X/Homebrew:

Try running postgres -D /usr/local/var/postgres -- it will give you a much more verbose output if postgres fails to start.

In my case, running rm -rf /usr/local/var/postgres && initdb /usr/local/var/postgres -E utf8 removed my old databases and then reinitialized the postgres db schema.

Thanks to https://github.com/Homebrew/homebrew/issues/35240 for that solution.

After regenerating my databases (with rake db:create) everything worked fine again.


Found a solution that worked for me here:

https://dba.stackexchange.com/questions/75214/psql-could-not-connect-to-server-no-such-file-or-directory

You basically run the following command to manually start the server:

pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start