could not connect to server: No such file or directory (PG::ConnectionBad)

I found that typing the following into terminal helps:

$ cd /usr/local/var/postgres/

$ rm postmaster.pid

I found this over at http://alumni.lewagon.org/questions/60

It also describes what might be happening. The file may get corrupt if Postgresql was not closed 'gracefully'. Example would be if your battery on your laptop were to die.


Looks like the postgres server isn't running. Start the server by running

 sudo service postgresql start