I installed PostgreSQL on a computer with Mac OS X using the One click installer. Then I try to access PostgreSQL using the psql command, but it doesn't seem to be available.

I get this message:

-bash: psql: command not found

Do I have to install something more? Or how can I configure PostgreSQL so I can use it on my computer?


Appears "the way" to install the client, if you want to use hombrew, is:

brew install postgresql

then psql (the client command line) will now be available to you (it also installs a local Postgres server/database, but you don't have to use that if all you want is the client).

Apparently there's also a 'wrapper' to the psql command to make it more "user friendly" also available via homebrew (brew install pgcli) in case interesting. Pgcli is a command line interface for Postgres with auto-completion and syntax highlighting.

Another option is to install the libpq homebrew package, but it doesn't get in your PATH.

brew install libpq

So follow the instructions it says after install out to add it to your PATH, or brew link --force libpq or add a symlink.

  • 6
    Apparently there's no way of using psql without installing the whole database engine. I found pgcli more convenient for when for instance you want to have all your services dockerized. Way to go @rogerdpack! Dec 31 '17 at 20:10
  • If all you need is the cli, I'd recommend having a look at the @luril answer below.
    – dbaltor
    Apr 20 at 17:12
  • 1
    Note about these comments suggesting pgcli to avoid installing the whole database engine - the pgcli docs state that installing pgcli will also install postgresql if it doesn't exist yet. pgcli.com/install
    – Neal
    Oct 8 at 16:46

Locate the psql binary. (In a terminal, run locate psql | grep /bin, and make note of the path. (In my case, it's /opt/local/lib/postgresql90/bin/, as it was installed using MacPorts.)

Then, edit the .bash_profile file in your home folder (e.g. mate -w ~/.bash_profile assuming you've textmate), and add the needed line so it's in your path, e.g.:

export PATH=/opt/local/lib/postgresql90/bin/:$PATH

After having saved the file, read the file (. ~/.bash_profile) or open a new terminal, and type psql.

  • 20
    Thanks, my path to psql was /Library/PostgreSQL/9.0/bin/psql and I created a .bash_profile file as you suggested and it works great.
    – Jonas
    May 28 '11 at 17:18
  • 1
    @Jonas: +1 Your comment should really go into a separate answer and should be the accepted answer, because this is the default location when installing Postgres on a Mac! Nov 20 '14 at 10:01
  • The locate command didn't work initially for me, I had to first run sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.locate.plist then wait for the find process to finish
    – magritte
    May 28 '17 at 17:10
  • 4
    better export PATH=/Applications/Postgres.app/Contents/Versions/latest/bin/:$PATH
    – andilabs
    Sep 22 '17 at 7:43
  • 1
    Another option, if you don't want to mess with your PATH settings is to simply add a symlink to a well known location, which is already in your path. For me that would be ln -s /Library/PostgreSQL/9.2/bin/psql /usr/local/bin/psql Dec 17 '18 at 21:42

I strongly recommend using Postgres.app from the Heroku team, which is also supported by them!

It has a menubar icon and the menu has a psql item:

Postgres.app menubar icon menu

You will also find psql included here if you want the same version of that as the server (path may vary by version):


If you want, you can add this path to your startup script to execute psql directly:


CAVEAT! AFAIK, Postgres.app doesn't support connections via Unix sockets (I am not sure what this is...), and supports only TCP/IP connections. So don't panic if you fail to connect there from some other programs.

  • 6
    The latest documentation postgresapp.com/documentation/cli-tools.html lists the path as /Applications/Postgres.app/Contents/Versions/latest/bin
    – Bryan Ash
    Jan 18 '16 at 23:36
  • Actually comment turns out to be a better answer :) May 4 '17 at 4:43
  • better export PATH=/Applications/Postgres.app/Contents/Versions/latest/bin/:$PATH
    – andilabs
    Sep 22 '17 at 7:43
  • I looked but couldn't find any relation between Heroku team and the app. Can you share how are they connected? Feb 14 '18 at 13:58

Install just client with brew:

brew install pgcli

then link it:

brew link --force libpq

as output you will get the path to psql:

If you need to have this software first in your PATH instead consider running:
  echo 'export PATH="/usr/local/opt/libpq/bin:$PATH"' >> ~/.zshrc

to find this path again:

brew info libpq

According to the installation guide after the installation has finished there should be shortcuts for StackBuilder, pgAdmin3 and psql in the Application folder of Postgres:

You will also find additional shortcuts to run pgAdmin, the psql command line interface and to access the PostgreSQL documentation.

If there are such shortcuts check where the psql's one is pointing.

  • Thanks, this aslo worked. I hadn't seen that documentation, only the documentation on postgresql.org.
    – Jonas
    May 28 '11 at 17:19

To highlight the comment: /Applications/Postgres.app/Contents/Versions/latest/bin – the folder of psql

  • please add more explantion, you have lesss than the comment
    – nbk
    Jan 30 at 14:34
brew install libpq    
brew link --force libpq 

I followed the below walkthrough and it worked. https://blog.timescale.com/tutorials/how-to-install-psql-on-mac-ubuntu-debian-windows/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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