How to install psql on a Mac
If you only need psql to reach a database that runs somewhere else, run brew install libpq and add its folder to your PATH yourself, since Homebrew deliberately doesn't. If you also want a PostgreSQL server on the Mac, Postgres.app bundles the server and psql in one app, and one line in Terminal puts psql on your PATH. EDB's installer, linked from postgresql.org, works too, but it always installs the server.

Three ways to get psql on a Mac
Homebrew: libpq
PostgreSQL's client tools, psql included, and no server. Needs one PATH line.
Postgres.app
A Mac app with a PostgreSQL server and the command line tools inside.
EDB installer
The installer linked from postgresql.org: server, command line tools and, if you like, pgAdmin.
Client or server?
psql is only a client. It connects to a PostgreSQL server and sends your SQL there. If the database lives somewhere else, on a server at work, in Docker or with a cloud host, the client is all you need. If you want a database on the Mac itself, install a server, and psql comes with it.
Client only, with Homebrew
Homebrew's libpq package is PostgreSQL's client library. It brings psql and the other client tools, such as pg_dump and pg_restore, but not the server.
- In Terminal, run
brew install libpq. - Homebrew installs libpq as keg-only: it doesn't link psql into your PATH, since that would clash with a full PostgreSQL install. So add the folder yourself:
echo 'export PATH="/opt/homebrew/opt/libpq/bin:$PATH"' >> ~/.zshrc. On an Intel Mac the folder is/usr/local/opt/libpq/bin. - Open a new Terminal window, or run
exec zsh, and check withpsql --version.
Installing psql with Homebrew
brew install libpqinstalls psql and the other client toolsecho 'export PATH=…' >> ~/.zshrcputs libpq's folder on your PATH (Apple silicon)exec zshreloads the shell so the new PATH appliespsql --versionchecks that psql is foundpsql -h localhost -U anna shopconnects: host, user, database\dtlists the tables\qquits psql
To connect, give psql the host after -h, the user after -U and then the database name. You can also paste a whole connection URL in quotes: psql "postgresql://anna@db.example.com:5432/shop". Inside psql, \dt lists the tables, \d customers shows the columns of one table, and \q quits.
With a server: Postgres.app
Postgres.app is an open-source Mac app that bundles a PostgreSQL server with the command line tools, psql included. Download it from postgresapp.com, move it to Applications, open it and click Initialize to start a server.
To use psql in any Terminal window, run this line from Postgres.app's documentation once: sudo mkdir -p /etc/paths.d && echo /Applications/Postgres.app/Contents/Versions/latest/bin | sudo tee /etc/paths.d/postgresapp. Close Terminal and open a new window. Now which psql should point inside Postgres.app.
Version 3.0 comes with PostgreSQL 19 and needs macOS 11 or later.
With a server: the EDB installer
The first option on postgresql.org's macOS download page is an interactive installer made by EDB. It installs the server and the command line tools, plus pgAdmin 4 and Stack Builder if you want them. EDB's own guide says the server and the command line tools can't be left out, so it's more than you need for psql alone.
psql ends up in /Library/PostgreSQL/, then the version number, then /bin. Add that folder to your PATH in ~/.zshrc, the same way as for Homebrew above.
If zsh says command not found: psql
zsh: command not found: psql nearly always means psql is installed but not on your PATH.
- With Homebrew's libpq, the PATH line is missing, or the Terminal window was already open when you added it. Check that
/opt/homebrew/opt/libpq/bin/psql --versionanswers, then open a new window. - With Postgres.app, run the /etc/paths.d line above and open a new window.
- Have more than one psql?
which -a psqllists them in the order the shell tries them.
A newer psql connects fine to an older server, so psql 19 works against PostgreSQL 17. The other way round, psql warns you that some features might not work.
If you'd rather click
psql is quick once you know the backslash commands, but a wide table in Terminal is hard to read. Tabel, the Mac database client I make, connects to PostgreSQL without psql or anything else installed. Paste the same connection URL, and the tables appear in the sidebar. The SSH tunnel is built in. Tabel costs $4.99, once.


- Table and column names complete as you type
- ⌘↩ runs the statement under the cursor
- Each connection's environment, in colour
- 1,000 rows per page, plus the query time
Looking for a graphical client in general? PostgreSQL GUI clients for Mac compares seven of them, and How to install and use pgAdmin on a Mac covers the free, official one.