Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?


share|improve this question

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.

share|improve this answer

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)

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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