Search code examples
macososx-mountain-lionpostgresql-9.2rails-postgresql

Why is Brew installed postgres looking here?


Why is brew installed postgres looking for /tmp/.s.PGSQL.5432 when I specified /var/pgsql_socket (unix_socket_directory = '/var/pgsql_socket') in my postgresql.conf?

Install was successful. I can start and stop Pg successfully.

My PATH and PGHOST env vars seem to be set up correctly, but when I try psql, I cannot connect?

PATH="/usr/local/bin:$PATH"
PGHOST="/var/pgsql_socket"

Any ideas? I've read 1000 posts, and nothing seems to fit my situation and provide a fix?

enter image description here


Solution

  • Changing the unix_socket_directory in postgresql.conf only affects where the server puts the socket directory. postgresql.conf isn't readable by clients, and clients can't ask the server about settings until they can connect, so a chicken-and-egg problem prevents the client asking the server how to connect.

    You need to tell psql where the socket directory is. It appears you've already done this with pghost, so my guess is that you haven't exported the environment variables:

    export PGHOST="/var/pgsql_socket"
    

    or

    psql -h /var/pgsql_socket