Hi, we’re Timescale! We build a faster PostgreSQL for demanding workloads like time series, vector, events, and analytics data. Check us out.

Back to blog
7 min read
Aug 22, 2019
Table of contents
01 Before You Start02 Install on macOS Using Homebrew03 Install on Ubuntu (22.04, 24.04, 26.04) and Debian 1304 Install on Fedora, RHEL, Rocky, and AlmaLinux05 Install on Windows 1106 Last Step: Connect to Your PostgreSQL Server07 Related resources: psql + Postgres08 About TimescaleDB and PostgreSQL Queries09 FAQs: How to Install psql on Mac, Ubuntu, Debian, WindowsPostgreSQL for time series and events
Engineered for powerful price-performance and speed.
Learn more about Tiger Datapsql 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 --versionIf psql isn't installed (or you want to upgrade to a newer client), keep reading.
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 libpq3. 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:
/opt/homebrew/usr/localYou don't have to know which, brew --prefix libpq will figure it out. For zsh (the default shell since macOS Catalina):
shell echo 'export PATH="'$(brew --prefix libpq)'/bin:$PATH"' >> ~/.zshrc source ~/.zshrc 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 libpqSkip 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@18This installs the server, psql, and all the client tools in one shot.
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).
shell sudo apt update
sudo apt install postgresql-client 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.
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
Full instructions: apt.postgresql.org.
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.
You have several reasonable options on Windows. Pick whichever matches your workflow.
winget (built into Windows 11)winget install PostgreSQL.PostgreSQL.18choco install postgresql18scoop install postgresqlIf you prefer a GUI wizard, download the EDB-built installer from postgresql.org. This installs the server, psql, pgAdmin, and the rest.
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.
Let’s confirm that psql is installed:
psql --versionNow, in order to connect to your PostgreSQL server, we’ll need the following connection params:
There are two ways to use these params.
psql -h [HOSTNAME] -p [PORT] -U [USERNAME] -W -d [DATABASENAME]Once you run that command, the prompt will ask you for your password. (Which we specified with the -W flag.)
"postgresql://[USERNAME]:[PASSWORD]@[HOSTNAME]:[PORT]/[DATABASENAME]?sslmode=verify-full"Note: the canonical scheme is postgresql://. The shorter postgres:// works as an alias, but postgresql:// is what you'll see in the official docs.
sslmodeDon'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:

Congrats! Now you have connected via psql.
Now that you've installed psql, you are ready to start easily interacting with your PostgreSQL—or TimescaleDB—database.
TimescaleDB is built on PostgreSQL and expands its capabilities for time series, analytics, and events. It will make your queries faster via automatic partitioning, query planner enhancements, improved materialized views, columnar compression, and much more. Plus, you can scale PostgreSQL for cheap with our multi-tiered storage backend.
If you're running your PostgreSQL database on your own hardware, you can simply add the TimescaleDB extension. If you prefer to try TimescaleDB in AWS, create a free account on our platform today. It only takes a couple of seconds, no credit card required!
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="'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.
About the author

By Ajay Kulkarni

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.
Read more
Receive the latest technical articles and release notes in your inbox.