TigerData logo
TigerData logo
  • Product

    Product

    Tiger Cloud

    Robust elastic cloud platform for startups and enterprises

    TimescaleDB Enterprise

    Self-managed TimescaleDB for on-prem, edge and private cloud

    Open source

    TimescaleDB

    Time-series, real-time analytics and events on Postgres

    Search

    Vector and keyword search on Postgres

  • Industry

    Data Centers

    Energy & Utilities

    Oil & Gas Operations

    Smart Manufacturing

    Crypto

  • Docs
  • Pricing
  • Developer Hub

    Changelog

    Benchmarks

    Blog

    Community

    Customer Stories

    Events

    Support

    Integrations

    Launch Hub

  • Company

    About

    TigerData logo

    Timescale

    Partners

    Security

    Careers

Contact usStart a free trial
Tiger Data

Products

  • TimescaleDB
  • Tiger Cloud
  • TimescaleDB Enterprise
  • Postgres Search Stack

Industry

  • Data Centers
  • Energy & Utilities
  • Oil & Gas Operations
  • Smart Manufacturing
  • Crypto

Support

  • Cloud Status
  • Support
  • Security
  • Terms of Service
  • Code Of Conduct

Learn

  • Documentation
  • Blog
  • Tutorials
  • Changelog
  • Success Stories

Company

  • About
  • Contact Us
  • Careers
  • Newsroom
  • Brand
  • Events

Products

  • TimescaleDB
  • Tiger Cloud
  • TimescaleDB Enterprise
  • Postgres Search Stack

Industry

  • Data Centers
  • Energy & Utilities
  • Oil & Gas Operations
  • Smart Manufacturing
  • Crypto

Support

  • Cloud Status
  • Support
  • Security
  • Terms of Service
  • Code Of Conduct

Learn

  • Documentation
  • Blog
  • Tutorials
  • Changelog
  • Success Stories

Company

  • About
  • Contact Us
  • Careers
  • Newsroom
  • Brand
  • Events
Privacy preferencesLegalPrivacySitemap

Subscribe to the Tiger Data newsletter

Gold Partner with Inductive Automation — Ignition

2026 (c) Timescale, Inc., d/b/a Tiger Data.
All rights reserved.

Tiger Data
GOLD PARTNER WITHINDUCTIVE AUTOMATION

2026 (c) Timescale, Inc., d/b/a Tiger Data.
All rights reserved.

Privacy preferencesLegalPrivacySitemap

How to Install psql on Mac, Ubuntu, Debian, Windows

Ajay Kulkarni

By Ajay Kulkarni

August 22nd, 2019

7 min

Share

Ajay Kulkarni

By Ajay Kulkarni

August 22nd, 2019

7 min

Share

Copy as HTML

Open in ChatGPT

Open in Claude

Open in v0

Tutorials

PostgreSQL

#CTA-homepage

#Callout-technical

Table of contents

  1. 01 Before You Start
  2. 02 Install on macOS Using Homebrew
  3. 03 Install on Ubuntu (22.04, 24.04, 26.04) and Debian 13
  4. 04 Install on Fedora, RHEL, Rocky, and AlmaLinux
  5. 05 Install on Windows 11
  6. 06 Last Step: Connect to Your PostgreSQL Server
  7. 07 Related resources: psql + Postgres
  8. 08 About TimescaleDB and PostgreSQL Queries
  9. 09 FAQs: How to Install psql on Mac, Ubuntu, Debian, Windows
Learn more about Tiger Data
A fierce PostgreSQL elephant (How to Install psql on Mac, Ubuntu, Debian, Windows)

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.

💡
Need a refresher on Postgres and psql commands? Check out our 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:

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.

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

⭐
Related documentation: Installing self-hosted TimescaleDB on 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 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.

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

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

Install on Fedora, RHEL, Rocky, and AlmaLinux

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:

  • Hostname
  • Port
  • Username
  • Password
  • Database name

There are two ways to use these params.

Option 1:

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:

"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:

image

Congrats! Now you have connected via psql.

Related resources: psql + Postgres

  • Connect with psql
  • PostgresSQL extensions
  • Manual PostgresSQL configuration and tuning
  • A Guide to Scaling PostgreSQL

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 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!

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:(brew --prefix libpq)'/bin:(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.


About the author

Ajay Kulkarni

By Ajay Kulkarni

// Related posts

Yes, You Can Do Hybrid Search in Postgres (And You Probably Should)
Yes, You Can Do Hybrid Search in Postgres (And You Probably Should)

pg_textsearch

Cloud

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.

By Erin Mikail Staples

April 20th, 2026

How to Automate Data Classification in PostgreSQL With OpenAI
How to Automate Data Classification in PostgreSQL With OpenAI

AI

#Callout-pgaivector

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.

By Team Tiger Data

November 22nd, 2024

Combining Semantic Search and Full-Text Search in PostgreSQL (With Cohere, Pgvector, and Pgai)
Combining Semantic Search and Full-Text Search in PostgreSQL (With Cohere, Pgvector, and Pgai)

AI

#Callout-pgaivector

Combining Semantic Search and Full-Text Search in PostgreSQL (With Cohere, Pgvector, and Pgai)

Read how you can implement hybrid search in PostgreSQL by combining semantic and full-text search using Cohere, pgvector, and pgai.

By Team Tiger Data

November 15th, 2024

Stay updated with new
posts and releases.

Receive the latest technical articles and release notes in your inbox.