Postgres could not connect to server

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

The reason for the issue is because a pid file was blocking postgres from starting up. To fix it:

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

and then all is well.