How to Check the PostgreSQL Version

PostgreSQL, often known simply as Postgres, is an open-source object-relational database management system.
Knowing which version is running on your system matters when you are installing an application that requires a specific PostgreSQL release, planning an upgrade, or troubleshooting compatibility issues.
This guide covers the most common ways to check the PostgreSQL version from the command line and from within a database session.
PostgreSQL Versioning
PostgreSQL releases follow a MAJOR.MINOR versioning scheme.
The MAJOR number increases with each annual release that introduces new features. Starting with PostgreSQL 10, each major version increments by one (10, 11, 12, … 16, 17). Before version 10, major versions used a two-part number such as 9.4 or 9.6.
The MINOR number covers bug fixes and security patches within a major release. For example, 17.1 and 17.2 are both part of the PostgreSQL 17 major release. Each major release receives security and bug-fix updates for five years.
The current major version is PostgreSQL 18.
Using the Command Line
To check the PostgreSQL server version, run the postgres binary with the --version or -V flag:
postgres --versionThe command prints the version and exits:
postgres (PostgreSQL) 17.2You can also check the version of the psql client utility:
psql --versionpsql (PostgreSQL) 17.2psql is the interactive terminal for PostgreSQL. Its version usually matches the server version, but they can differ if the client and server packages were installed separately.
Binary not found
If the postgres binary is not in your system’s PATH
, you will get a “command not found” error. This usually happens when PostgreSQL was installed outside the distribution’s standard repositories.
Use the find
command to locate the binary:
sudo find /usr -wholename '*/bin/postgres'/usr/lib/postgresql/17/bin/postgresOnce you have the path, pass it directly to get the version:
/usr/lib/postgresql/17/bin/postgres -VUsing the SQL Shell
You can also check the version from within an active database session. Connect to the PostgreSQL shell with psql:
sudo -u postgres psqlThe following query returns the full version string including build details:
SELECT version(); version
----------------------------------------------------------------------------------------------------------------------------------
PostgreSQL 17.2 on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 13.2.0-23ubuntu4) 13.2.0, 64-bit
(1 row)To get just the version number, use SHOW instead:
SHOW server_version; server_version
----------------
17.2
(1 row)SHOW server_version is useful in scripts or monitoring queries where you only need the bare version string.
Quick Reference
| Method | Command |
|---|---|
| Server binary | postgres --version |
| Client binary | psql --version |
| Full version string (SQL) | SELECT version(); |
| Version number only (SQL) | SHOW server_version; |
| Find binary path | sudo find /usr -wholename '*/bin/postgres' |
Conclusion
For a quick check from the shell, postgres --version is all you need. Inside a running session, SHOW server_version returns just the version number and works well in scripts or monitoring queries.
Tags
Linuxize Weekly Newsletter
A quick weekly roundup of new tutorials, news, and tips.
About the authors

Dejan Panovski
Dejan Panovski is the founder of Linuxize, an RHCSA-certified Linux system administrator and DevOps engineer based in Skopje, Macedonia. Author of 800+ Linux tutorials with 20+ years of experience turning complex Linux tasks into clear, reliable guides.
View author page