Socket File “/var/pgsql_socket/.s.PGSQL.5432” Missing In Mountain Lion (OS X Server)

I was able to add the following to my .bash_profile to prevent the error:

export PGHOST=localhost

This works because:

If you omit the host name, psql will connect via a Unix-domain socket to a server on the local host, or via TCP/IP to localhost on machines that don’t have Unix-domain sockets.

Your OS supports Unix domain sockets, but PostgreSQL’s Unix socket that psql needs either doesn’t exist or is in a different location than it expects.

Specifying a hostname explicitly as localhost forces psql to use TCP/IP. Setting an environment variable PGHOST is one of the ways to achieve that. It’s documented in psql’s manual.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)