How To Check PostgreSQL Version
One of the first questions I ask when stepping into a new project is:“What version of PostgreSQL are we running?”. Whether you’re a developer or a DBA, knowinghow to check your PostgreSQL versionis the fundamental first step in database management. In this article, I’ll show you exactly how to find that information using every tool.Table of ContentsHow To Check PostgreSQL VersionMethod 1: The SQL Query (For Active Sessions)If you are already logged into a database tool likepsql, DBeaver, or pgAdmin, the fastest way to get your version is a simple SQL query.Using theversion()FunctionThis is the “gold standard” query. It returns a detailed string containing the version, the operating system, and the compiler used.SQLSELECT version();UsingSHOW server_versionIf you just want the clean version number without the extra system “noise,” this is your best approach:SQLSHOW server_version;Usingserver_version_numFor those of you writing automation scripts, you’ll want the numeric version. This returns an integer (e.g.,180002for version 18.2), making it much easier to handle “greater than” or “less than” logic in your code.SQLSHOW server_version_num;CommandBest ForExample OutputSELECT version();Detailed system infoPostgreSQL 18.2 on x86_64-pc-linux-gnu...SHOW server_version;Human-readable version18.2SHOW server_version_num;Scripting/Automation180002Method 2: The Command Line (Before You Connect)If you’re a system administrator, you might be working directly in the Linux terminal or Windows Command Prompt. You can check the version without even logging into the database.Checking the Client Version (psql)Thepsqlutility is the front-end tool. Keep in mind that theclientversion and theserverversion can be different!Bashpsql --version # OR psql -VChecking the Server Version (postgres)If you have access to the server binaries, you can query the engine itself:Bashpostgres --version # OR postgres -VExpert Note:If you get acommand not founderror, it usually means your PATH environment variable isn’t set up correctly. This is common in standard Linux installations in AWS EC2 instances. You may need to use the full path, such as/usr/lib/postgresql/18/bin/postgres -V.Method 3: Checking via GUI Tools (pgAdmin DBeaver)If you like to use a GUI approach.In pgAdmin 4:OpenpgAdminand connect to your server.Select your server in theBrowsertree on the left.Click thePropertiestab in the main dashboard.Look for theVersionfield.In DBeaver:Right-click your connection in theDatabase Navigator.SelectEdit Connection.Click onTest Connection. The resulting pop-up will show the server version details.Understanding PostgreSQL Versioning SyntaxStarting with version 10, PostgreSQL moved to a simplifiedMajor.Minorformat. This was a huge win for clarity.Major Version (e.g., 18):Released once a year (usually in September). This brings new features and sometimes breaking changes.Minor Version (e.g., .2):Released quarterly. These are strictly for bug fixes and security patches. They donotchange the internal data format.Professional Best Practices for Version ManagementStay Current on Minors:Always apply minor updates within 30 days of release. They are low-risk and keep you secure.Plan for Majors:Treat a major version upgrade (e.g., 17 to 18) as a project. Test your application in a staging environment first.Check EOL:PostgreSQL versions are supported for5 years. If you are still running version 12 in 2026, you are officially “out of support” and at high risk.Summary of CommandsContextCommandInside SQL ShellSELECT version();Inside SQL ShellSHOW server_version;Linux/macOS Terminalpsql --versionWindows CMDpostgres -VAutomationSHOW server_version_num;ConclusionKnowing how to check your PostgreSQL version is about ensuring your environment is compatible, secure, and performing at its peak. Whether you prefer the command line or a GUI, make it a habit to verify your version regularly.