Home → Articles → How to Install PostgreSQL Database Server on Ubuntu 26.04

How to Install PostgreSQL Database Server on Ubuntu 26.04

26 Apr, 2026

Introduction

PostgreSQL is a free, open-source relational database management system that offers advanced features and supports many modern programming languages like Python, Java, C++, PHP, Golang, and Node.js. The database server handles flexible data types and supports different operating systems. These features make PostgreSQL a powerful and versatile choice for developers and businesses.

This guide shows you how to install PostgreSQL on Ubuntu 26.04.

Prerequisites

Before you start:

Install PostgreSQL

The PostgreSQL package is available by default on the Ubuntu repositories. To install the package, follow these steps.

Manage PostgreSQL Service

PostgreSQL runs as a system service on Ubuntu under the name postgresql. You can manage this service by using specific commands to start, stop, restart, and check the PostgreSQL status. These commands ensure your PostgreSQL server runs smoothly and make maintenance easier on your system.

Check PostgreSQL Status

console
$ sudo systemctl status postgresql

Output:

● postgresql.service - PostgreSQL RDBMS
     Loaded: loaded (/usr/lib/systemd/system/postgresql.service; enabled; preset: enabled)
     Active: active (exited) since Tue 2026-03-10 10:15:23 UTC; 5min 12s ago
    Process: 1143 ExecStart=/bin/true (code=exited, status=0/SUCCESS)
   Main PID: 1143 (code=exited, status=0/SUCCESS)
        CPU: 2ms

Press Ctrl + C to return to the shell prompt

Enable PostgreSQL to Start on Boot

console
$ sudo systemctl enable postgresql

Output:

Synchronizing state of postgresql.service with SysV service script with /usr/lib/systemd/systemd-sysv-install.
Executing: /usr/lib/systemd/systemd-sysv-install enable postgresql

Start PostgreSQL Service

console
$ sudo systemctl start postgresql

Stop PostgreSQL Service

console
$ sudo systemctl stop postgresql

Restart PostgreSQL Service

console
$ sudo systemctl restart postgresql

Secure PostgreSQL Database Server

By default, you can log in to your PostgreSQL server using the postgres user account without a password on your localhost. To secure the postgres user account with a password, follow the steps below.

Test the PostgreSQL Database Server

In this section, you'll test PostgreSQL by logging into the database server, creating a sample database and table, inserting some data, and querying the table to ensure everything functions correctly.

Your PostgreSQL database server is working as expected.

Conclusion

In this guide, you have installed PostgreSQL on Ubuntu 26.04 using apt, secured the database server with a password, and created a sample database with tables and records. Now that you have PostgreSQL running, consider integrating the database with a programming language like Python using psycopg2 or with Node.js using the pg package to build data-driven applications.