Posted in

How to Check PostgreSQL Version: Easy Guide for  Developers & Beginners

PostgreSQL (often called Postgres) is one of the most popular open-source databases in India. It is widely used by students, startups, web developers, and companies working on Django, Node.js, Spring Boot, or full-stack projects. Knowing your PostgreSQL version helps ensure compatibility, use new features, apply security updates, and troubleshoot issues.

This guide explains several easy ways to check the PostgreSQL version using command-line tools, SQL queries, and database management utilities.

How to Check PostgreSQL Version

Why Should You Check PostgreSQL Version?

  • New versions (like PostgreSQL 16 or 17 in 2026) bring better performance, security, and features.
  • Check compatibility with your application, ORM (like Prisma, SQLAlchemy), or extensions.
  • During interviews, recruiters often ask “How do you check PostgreSQL version?”
  • Troubleshoot errors like “feature not supported” in older versions.
  • Plan upgrades safely on local machines, VPS (AWS, DigitalOcean, Railway), or cloud services.

1. Check Version Using Command Line (Fastest Method)

This works on Windows, Linux, and macOS.

Using psql Command

  1. Open Command Prompt (Windows) or Terminal (Linux/macOS).
  2. Type the following and press Enter: psql –version
    or
    psql -V

You will see output like: psql (PostgreSQL) 16.4

Check Server Version

postgres –version

or

pg_ctl –version

On Linux / Ubuntu (Very Common in India):

sudo -u postgres psql –version

or check installed package: apt show postgresql

On Windows:

Make sure PostgreSQL bin folder is added to your system PATH. Usually located at C:\Program Files\PostgreSQL\16\bin.

On macOS (using Homebrew):

brew list postgresql

or simply use psql –version.

2. Check Version Inside PostgreSQL Shell (psql)

This shows the exact server version you are connected to.

  1. Open terminal/cmd.
  2. Type psql and press Enter (or psql -U postgres if needed).
  3. Once you see the postgres=# prompt, run this SQL command:
    SQL
  4. SELECT version();
  5. Press Enter.
  6. You will get detailed information like: PostgreSQL 16.4 on x86_64-pc-linux-gnu…

Other useful queries:

SQL

— Just the version number

SHOW server_version;

— Full build info

SELECT * FROM pg_settings WHERE name = ‘server_version’;

One-liner without entering shell: psql -c “SELECT version();”

3. Using pgAdmin (GUI Tool – Best for Beginners)

pgAdmin is the official graphical tool for PostgreSQL, very popular among  students.

  1. Open pgAdmin 4.
  2. Connect to your database server.
  3. Right-click on the server name in the left panel.
  4. Click Properties or go to Dashboard tab.
  5. You will see the PostgreSQL version clearly displayed.
  6. Alternatively, open Query Tool and run SELECT version();.

4. Check Version on Cloud Platforms

Many  developers use cloud databases:

  • Supabase / Neon / Railway: Go to your project dashboard → Database settings → You can see the version.
  • AWS RDS: In AWS Console → RDS → Databases → Click your instance → Configuration tab.
  • Google Cloud SQL: In GCP Console → SQL → Instance details.
  • Docker Container: docker exec -it <container_name> psql -c “SELECT version();”
    or
    docker exec -it <container_name> postgres –version

5. Check Version from Application Code

Node.js

JavaScript

const { Client } = require(‘pg’);

const client = new Client({ connectionString: ‘your_connection_string’ });

async function checkVersion() {

await client.connect();

const res = await client.query(‘SELECT version()’);

console.log(res.rows[0].version);

await client.end();

}

checkVersion();

Python (psycopg2 or psycopg)

Python

import psycopg2

conn = psycopg2.connect(“dbname=test user=postgres”)

cur = conn.cursor()

cur.execute(“SELECT version();”)

print(cur.fetchone()[0])

cur.close()

conn.close()

6. Other Useful Methods

  • Service Status on Linux: systemctl status postgresql
  • Installed Packages: dpkg -l | grep postgresql   # Ubuntu/Debian rpm -qa | grep postgresql # CentOS/RHEL
  • Data Directory: Look for PG_VERSION file inside the data folder.

Common Issues & Troubleshooting (Faced by  Developers)

  • “psql: command not found”: Add PostgreSQL bin to PATH or use full path.
  • Permission denied: Use sudo -u postgres psql on Linux.
  • Multiple versions installed: Check active version with which psql.
  • Port conflict: Default port is 5432. Use psql -p 5433 if using different port.
  • Password prompt: Set PGPASSWORD environment variable or use pgAdmin.
  • Docker / WSL: Run commands inside the container.
  • Old version on shared hosting: Many cheap hostings still use PostgreSQL 12 or 13 — consider migrating.

Tips for  Users

  • Learning & Projects: Install the latest stable version from the official PostgreSQL website or use apt install postgresql on Ubuntu.
  • Free Resources: Follow free tutorials on YouTube (Telusko, CodeWithHarry, freeCodeCamp) and PostgreSQL official docs.
  • Development Setup: Use Docker Compose for easy version management in MERN/MEAN/Django projects.
  • Production: Always test upgrades on staging first. Use tools like pg_upgrade.
  • Interview Preparation: Remember psql –version and SELECT version(); — these are the most asked methods.
  • Community: Join developer groups on Telegram, Discord, or Reddit (r/developersIndia, r/postgresql).

Conclusion

Checking your PostgreSQL version is very easy. The quickest ways are:

  • psql –version (command line)
  • SELECT version(); (inside psql)

Save this article, bookmark the commands, or take screenshots for quick reference. Keeping your PostgreSQL version updated ensures better performance, security, and access to modern features.

Whether you are a beginner learning database concepts or an experienced developer deploying apps, these methods will save you time and reduce frustration.

Share this guide with your classmates, colleagues, or team members. Happy coding and database management!

Note: Commands and steps are valid as of 2026. Always refer to the official PostgreSQL documentation (postgresql.org) for the latest information specific to your operating system and setup.