---
title: "How to Install psql on Mac, Ubuntu, Debian, Windows"
published: 2019-08-22T15:21:00.000-04:00
updated: 2026-06-01T14:52:20.000-04:00
excerpt: "Instructions on how to get psql setup on a variety of operating systems.
"
tags: Tutorials, PostgreSQL, #CTA-homepage, #Callout-technical
authors: Ajay Kulkarni
---

> **TimescaleDB is now Tiger Data.**

`psql` is a terminal-based front-end to [PostgreSQL](https://www.tigerdata.com/learn/postgres-basics). 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](https://www.tigerdata.com/blog/connecting-to-postgres-with-psql-and-pg_service-conf), 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.

<iframe width="200" height="113" src="https://www.youtube.com/embed/iPFLdGnJcDw?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen="" title="What is psql?"></iframe>

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.

💡

Need a refresher on Postgres and [psql commands](https://www.tigerdata.com/blog/10-psql-commands-that-will-make-your-life-easier)? Check out our [Postgres Cheat Sheet](https://www.tigerdata.com/learn/postgres-cheat-sheet).

## Before You Start

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:

```shell
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.

💡

[Forgot how to connect to your Postgres services? You can use the .pg\_service.conf file, or if you're a TimescaleDB user, just click one button.](https://www.tigerdata.com/blog/connecting-to-postgres-with-psql-and-pg_service-conf)

## Install on macOS Using Homebrew

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
​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):

```shell
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
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
shell brew install postgresql@18
```

This installs the server, `psql`, and all the client tools in one shot.

⭐

Related documentation: [Installing self-hosted TimescaleDB on macOS](https://www.tigerdata.com/docs/get-started/choose-your-path/install-timescaledb#tab=macos).

## 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).

### Option A: Default apt repos (quick and dirty)​

```shell
​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.

### 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.

```shell
# 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](https://apt.postgresql.org).

💡

****Editor's Note****: For information about how to connect psql to your TimescaleDB database, please refer to [Tiger Data documentation on connecting to your database with psql](https://www.tigerdata.com/docs/integrate/query-administration/psql).

## Install on Fedora, RHEL, Rocky, and AlmaLinux

For RPM-based distros, `psql` is in the standard repos:

```shell
​shell sudo dnf install postgresql ​
```

For the current major version, use the PostgreSQL Yum repository — see [yum.postgresql.org](https://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)

```powershell
winget install PostgreSQL.PostgreSQL.18
```

### Option 2: Chocolatey

```powershell
choco install postgresql18
```

### Option 3: Scoop

```powershell
scoop install postgresql
```

### Option 4: Official PostgreSQL installer

If you prefer a GUI wizard, download the EDB-built installer from [postgresql.org](https://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:

```shell
psql --version
```

Now, in order to connect to your PostgreSQL server, we’ll need the following connection params:

-   Hostname
-   Port
-   Username
-   Password
-   Database name

There are two ways to use these params.

### Option 1:

```shell
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.)

### Option 2:

```shell
"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.

### 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](https://console.cloud.tigerdata.com/signup):

![](https://storage.ghost.io/c/6b/cb/6bcb39cf-9421-4bd1-9c9d-fa7b6755ba0e/content/images/2026/06/data-src-image-d12affb5-b6ef-4bec-a7e2-e14f7e2b474e.png)

Congrats! Now you have connected via `psql`.

## Related resources: psql + Postgres

-   [Connect with psql](https://www.tigerdata.com/docs/integrate/query-administration/psql)
-   [PostgresSQL extensions](https://www.tigerdata.com/docs/deploy/tiger-cloud/tiger-cloud-aws/tiger-cloud-extensions)
-   [Manual PostgresSQL configuration and tuning](https://www.tigerdata.com/docs/deploy/self-hosted/configuration/postgres-config)
-   [A Guide to Scaling PostgreSQL](https://www.tigerdata.com/learn/guide-to-postgresql-scaling)

## About TimescaleDB and PostgreSQL Queries

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](https://www.tigerdata.com/blog/postgresql-timescaledb-1000x-faster-queries-90-data-compression-and-much-more) via [automatic partitioning](https://www.tigerdata.com/learn/is-postgres-partitioning-really-that-hard-introducing-hypertables), query planner enhancements, improved materialized views, [columnar compression](https://www.tigerdata.com/blog/building-columnar-compression-in-a-row-oriented-database), and much more. Plus, [you can scale PostgreSQL for cheap with our multi-tiered storage backend](https://www.tigerdata.com/blog/scaling-postgresql-for-cheap-introducing-tiered-storage-in-timescale).

If you're running your PostgreSQL database on your own hardware, [you can simply add the TimescaleDB extension](https://www.tigerdata.com/docs/get-started/choose-your-path/install-timescaledb). If you prefer to try TimescaleDB in AWS, [create a free account on our platform today](https://console.cloud.tigerdata.com/signup). It only takes a couple of seconds, no credit card required!

## 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 --prefix libpq)'/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](https://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.