Hi, we’re Timescale! We build a faster PostgreSQL for demanding workloads like time series, vector, events, and analytics data. Check us out.
psql is a terminal-based front-end to PostgreSQL. It provides an interactive command-line interface to the PostgreSQL (or TimescaleDB) database. With psql, you can type in queries interactively, issue them to PostgreSQL, and see the query results. It also provides several meta-commands and various shell-like features to facilitate writing scripts and automating a wide variety of tasks.
For instance, users can create, modify, and delete database objects such as tables, views, or users using psql. They can also execute SQL commands, manage data within the database, and even customize the psql environment.
Since psql is the standard command line interface for interacting with a PostgreSQL or TimescaleDB instance, this article will show you how to install it on a variety of operating systems.
Before you start, you should confirm that you don’t already have psql installed. In fact, if you’ve ever installed Postgres or TimescaleDB before, you likely already have psql installed.
To verify it, open the command line program and type the following:
psql --version
If psql isn't installed (or you want to upgrade to a newer client), keep reading.
A quick note on version compatibility
Your psql client version should be greater than or equal to the PostgreSQL server you're connecting to. An older client against a newer server may not understand newer features and can give confusing output. When in doubt, install the most recent psql. Clients are backwards-compatible with older servers, but not forwards-compatible with newer ones.
As of this writing, PostgreSQL 18 is the current major release. The instructions below default to PG 18; substitute `17` or another version if you have a specific reason to.
The cleanest way to install just the psql client on macOS is via Homebrew's libpq formula. (libpq is the official PostgreSQL client library — it ships with psql, pg_dump, pg_restore, and friends, without installing a server.)
1. Install Homebrew if you don't already have it. Homebrew is the de facto package manager for macOS.
2. Install libpq:
shell brew update brew install libpq
3. Make psql available on your PATH.libpq is "keg-only" in Homebrew, which means it isn't symlinked into your PATH by default (so it doesn't collide with Apple's bundled libpq, or with a full PostgreSQL install if you also have one).
The recommended approach is to add libpq's bin directory to your shell PATH. The path differs depending on your Mac's architecture:
Apple Silicon (M1, M2, M3, M4): Homebrew lives at /opt/homebrew
Intel Macs: Homebrew lives at /usr/local
You don't have to know which, brew --prefix libpq will figure it out. For zsh (the default shell since macOS Catalina):
If you're on bash, swap ~/.zshrc for ~/.bash_profile.
Alternative: force-link: if you don't have a full PostgreSQL install on the same machine and you want libpq's tools symlinked into Homebrew's main bin directory, you can run:
shell brew link --force libpq
Skip this if you already have postgresql installed via Homebrew (it'll collide).
Want the full PostgreSQL server too? Install the meta-package instead of libpq:
shell brew install postgresql@18
This installs the server, psql, and all the client tools in one shot.
Install on Ubuntu (22.04, 24.04, 26.04) and Debian 13
You have two options on apt-based distros: the default repos (easy, often a release or two behind), or the official PostgreSQL APT repository (PGDG — gives you the current major version).
This installs whatever psql version Ubuntu/Debian ships in their archive. On Ubuntu 26.04 that's a recent version; on older releases you may be one or two majors behind.
Note: this installs only the client, not the PostgreSQL server.
Option B: PostgreSQL APT repo (recommended for current versions)
The PostgreSQL project maintains its own apt repo with up-to-date packages for every supported major version. This is the right choice if you need a specific PG version or you want to stay current.
# Add the PGDG repo for your distribution
sudo install -d /usr/share/postgresql-common/pgdg
sudo curl -o /usr/share/postgresql-common/pgdg/apt.postgresql.org.asc \
--fail https://www.postgresql.org/media/keys/ACCC4CF8.asc
sudo sh -c 'echo "deb [signed-by=/usr/share/postgresql-common/pgdg/apt.postgresql.org.asc] \
https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" \
> /etc/apt/sources.list.d/pgdg.list'
# Install psql 18 (or whichever major version you need)
sudo apt update
sudo apt install postgresql-client-18
For RPM-based distros, psql is in the standard repos:
shell sudo dnf install postgresql
For the current major version, use the PostgreSQL Yum repository — see yum.postgresql.org for the per-distro repo file.
Install on Windows 11
You have several reasonable options on Windows. Pick whichever matches your workflow.
Option 1: winget (built into Windows 11)
winget install PostgreSQL.PostgreSQL.18
Option 2: Chocolatey
choco install postgresql18
Option 3: Scoop
scoop install postgresql
Option 4: Official PostgreSQL installer
If you prefer a GUI wizard, download the EDB-built installer from postgresql.org. This installs the server, psql, pgAdmin, and the rest.
Option 5: WSL (recommended for developers)
If you're using WSL with Ubuntu, just follow the Ubuntu/Debian instructions above inside your WSL shell. This is often the smoothest path if you're already living in WSL for development.
After installing, you may need to add the PostgreSQL bin directory to your PATH so that `psql` works from any terminal. The installer typically asks about this; if not, the directory is something like C:\Program Files\PostgreSQL\18\bin.
Last Step: Connect to Your PostgreSQL Server
Let’s confirm that psql is installed:
psql --version
Now, in order to connect to your PostgreSQL server, we’ll need the following connection params:
Note: the canonical scheme is postgresql://. The shorter postgres:// works as an alias, but postgresql:// is what you'll see in the official docs.
A word on sslmode
Don't blindly copy sslmode=require from old tutorials. Here's the actual difference:
- sslmode=require — encrypts the connection but does not verify the server's certificate. Vulnerable to man-in-the-middle attacks. - sslmode=verify-ca — verifies the certificate was signed by a trusted CA, but not the hostname. - sslmode=verify-full — verifies the cert chain and the hostname. Use this for production.
Tiger Cloud uses certificates signed by a public CA, so verify-full works out of the box — no custom CA bundle required.
If you are using the Tiger Data dashboard, this is how they look in the Tiger Data UI:
FAQs: How to Install psql on Mac, Ubuntu, Debian, Windows
Q: How do I check if psql is already installed on my system? You can verify if psql is already installed by opening your command line program and typing psql --version. If you've previously installed PostgreSQL or TimescaleDB, you likely already have psql installed, as it comes bundled with these installations.
Q: How do I install psql on macOS? Install Homebrew, then run brew update && brew install libpq. Because libpq is keg-only, add it to your PATH with echo 'export PATH="'(brew−−prefixlibpq)′/bin:PATH"' >> ~/.zshrc && source ~/.zshrc. On Apple Silicon Macs, Homebrew lives at /opt/homebrew; on Intel Macs, it's at /usr/local. The brew --prefix command handles the difference for you. If you want the full PostgreSQL server, install postgresql@18 instead.
Q: How do I install psql on Ubuntu or Debian? For a quick install, run sudo apt update && sudo apt install postgresql-client. This pulls whatever version your distro ships, which can lag behind upstream. To get the current major release (PG 18 as of May 2026), add the PostgreSQL APT repository (PGDG) and install postgresql-client-18 from there.
Q: What's the recommended way to install psql on Windows 11? On Windows 11 the easiest option is winget install PostgreSQL.PostgreSQL.18. Chocolatey (choco install postgresql18) and Scoop (scoop install postgresql) are also solid choices. If you want a GUI wizard, use the official EDB-built installer from postgresql.org. If you already use WSL, install psql inside WSL Ubuntu using the Linux instructions.
Q: How do I connect to a PostgreSQL server using psql? Use either flag-based form — psql -h [HOSTNAME] -p [PORT] -U [USERNAME] -W -d [DATABASENAME] (the -W prompts for password) — or the connection URI form — psql "postgresql://[USERNAME]:[PASSWORD]@[HOSTNAME]:[PORT]/[DATABASENAME]?sslmode=verify-full&sslrootcert=system". Both methods need your hostname, port, username, password, and database name.
Q: Should I worry about psql version vs server version?Yes — your psql client should be greater than or equal to the major version of the PostgreSQL server you're connecting to. Older clients against newer servers can produce confusing output or fail on new syntax. When in doubt, install the latest psql.
Q: What's the difference between sslmode=require and sslmode=verify-full? require encrypts the connection but does not verify the server's certificate, leaving you exposed to man-in-the-middle attacks. verify-full encrypts the connection and validates that the server's certificate chains to a trusted CA and matches the hostname you're connecting to. Use verify-full for production. Tiger Cloud uses a publicly trusted CA, so verify-full works without extra configuration.
Yes, You Can Do Hybrid Search in Postgres (And You Probably Should)
Most search stacks run four systems to answer one question. You don't need any of them. Build production hybrid search in Postgres with pg_textsearch for BM25, pgvectorscale for vector similarity, and Reciprocal Rank Fusion to combine them. One query. One database.
How to Automate Data Classification in PostgreSQL With OpenAI
Data classification is a crucial but challenging task. Learn how to automate it in PostgreSQL using open-source extensions (pgvector; pgai) and OpenAI models.