I have a production SQL dump file that I want to restore to my local psql db for debugging reasons.

I can't access psql via the terminal though pgAdmin3 works just fine. Here is the error I'm getting:

$ psql
psql: could not connect to server: Permission denied
    Is the server running locally and accepting
    connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"?

$ locate psql | grep /bin

I tried using sudo, no change. Any Idea why I can't connect w terminal on the mac and then restore the sql db dump locally?


2 Answers 2


Try specifying -h localhost as a psql parameter, to connect via tcp/ip rather than a unix socket.

Likely, your psql and postgresql have different ideas of the correct setting for unix_socket_directory. Especially seeing as you have at least two different builds of postgresql installed! You might want to make sure you're using the psql client that corresponds to your postgresql server, since they have different major versions that will have other benefits too. Failing that, you can give a unix socket directory name as the hostname, e.g. psql -h /tmp will look for /tmp/.s.PGSQL.5342.


You seem to have no fewer than four psql binaries on your system.
All other things being equal when you type psql in the terminal it will use the first one it finds (probably /usr/bin/psql -- the one that came with OS X).

Make sure you're using the psql command that matches the Postgres server you're running (you can modify your PATH= in the .profile file in your home directory or type the full path to the psql you want to use)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.