How to Install PostgreSQL on Ubuntu 26.04

How to install PostgreSQL on Ubuntu 26.04

PostgreSQL is an open-source relational database management system (RDBMS). This database management system uses the SQL query language, similar to MySQL. Developed by the Berkeley Computer Science Department, PostgreSQL has been a trusted database for approximately 30 years. PostgreSQL databases are widely used across mobile, web, and analytics applications. PostgreSQL can process data in tables that are related to each other. Generally, this database management system is widely used for various applications with complex data processing requirements. In this article, we will show you how to install PostgreSQL on Ubuntu 26.04 for the first time and outline considerations to keep in mind.

Prerequisites

  • An Ubuntu 26.04 VPS with at least 4GB of RAM is necessary
  • SSH access with sudo privileges, or root access

Conventions

# – given commands should be executed with root privileges either directly as a root user or by use of sudo command
$ – given commands should be executed as a regular user

Step 1. Update the System

First, we need to log in to our Ubuntu 26.04 VPS via SSH before installing PostgreSQL.

ssh master@IP_Address -p Port_number

Replace “master” with a user that has sudo privileges or root if necessary. Additionally, replace “IP_Address” and “Port_Number” with your server’s respective IP address and SSH port number. Next, let’s make sure that we’re on Ubuntu 26.04. You can verify it with this command:

$ lsb_release -a

You should get this as the output if your system is properly set up for PostgreSQL on Ubuntu 26.04.

No LSB modules are available.
Distributor ID:     Ubuntu
Description:   Ubuntu Resolute Raccoon 
Release:  26.04
Codename: resolute

Then run the following command to ensure all installed packages on the server are up to date.

$ sudo apt update 

That’s it, your system’s local list of available software packages and their versions from online repositories should be updated now before proceeding with anything related to PostgreSQL on Ubuntu 26.04.

Step 2. Install PostgreSQL

There are three methods to install PostgreSQL on Ubuntu 26.04: using the system’s default repository, using PostgreSQL’s official repository, or installing from source. In this tutorial, we will show you the easiest methods to get it up and running.

The easiest way is to use the Advanced Package Tool (apt). The installation is easy and straightforward. Execute the command below with apt for best compatibility.

$ sudo apt install postgresql

On an Ubuntu 26.04 system, PostgreSQL runs automatically upon installation, which is an advantage compared to some other distributions. To verify this, we can invoke this command.

$ sudo systemctl status postgresql

The command above will return an output similar to this.

master@ubuntu26:~$ sudo systemctl status postgresql
● postgresql.service - PostgreSQL RDBMS
     Loaded: loaded (/usr/lib/systemd/system/postgresql.service; enabled; preset: enabled)
     Active: active (exited) since Fri 2026-01-16 10:06:54 UTC; 13s ago
 Invocation: f1fe3cef114246d98614f3e41572489a
   Main PID: 5342 (code=exited, status=0/SUCCESS)
   Mem peak: 1.7M
        CPU: 8ms

Jan 16 10:06:54 ubuntu26 systemd[1]: Starting postgresql.service - PostgreSQL RDBMS...
Jan 16 10:06:54 ubuntu26 systemd[1]: Finished postgresql.service - PostgreSQL RDBMS.

We can also check the installed PostgreSQL version by running this command and confirming it meets the Ubuntu 26.04 requirements.

$ psql --version

You should see this in the output if PostgreSQL is installed correctly on Ubuntu 26.04.

psql (PostgreSQL) 17.6 (Ubuntu 17.6-1build1)

At the moment, there is no other option to install PostgreSQL as the APT repository for Ubuntu 26.04 is still unavailable. You can check and verify it in the official PostgreSQL repository if you need information about future options.

Step 3. Use PostgreSQL

Once PostgreSQL is installed, it should be automatically up and running, and a default database and user account called ‘postgres’ will be created during installation. To access the database, execute the following command in the Ubuntu 26.04 system.

$ sudo su - postgres

After switching to user postgres, we can execute this command to get into the PostgreSQL shell and begin exploring the features.

$ psql
postgres@ubuntu26:~$ psql
psql (17.6 (Ubuntu 17.6-1build1))
Type "help" for help.

postgres=#

Run \l to list the databases you have in your PostgreSQL on Ubuntu 26.04 environment.

ppostgres@ubuntu26:~$ psql
psql (17.6 (Ubuntu 17.6-1build1))
Type "help" for help.

postgres=# \l
                                                 List of databases
   Name    |  Owner   | Encoding | Locale Provider | Collate |  Ctype  | Locale | ICU Rules |   Access privileges   
-----------+----------+----------+-----------------+---------+---------+--------+-----------+-----------------------
 postgres  | postgres | UTF8     | libc            | C.UTF-8 | C.UTF-8 |        |           | 
 template0 | postgres | UTF8     | libc            | C.UTF-8 | C.UTF-8 |        |           | =c/postgres          +
           |          |          |                 |         |         |        |           | postgres=CTc/postgres
 template1 | postgres | UTF8     | libc            | C.UTF-8 | C.UTF-8 |        |           | =c/postgres          +
           |          |          |                 |         |         |        |           | postgres=CTc/postgres
(3 rows)

postgres=# 

To exit from the PostgreSQL shell, simply run \q, then hit ENTER when you finish.

Step 4. Allow Remote Connections

By default, PostgreSQL is configured to listen only on localhost. It means you cannot access your PostgreSQL server remotely if you just finished a local installation. To configure PostgreSQL to listen on all available network addresses, let’s edit the configuration file.

$ sudo nano /etc/postgresql/17/main/postgresql.conf

Uncomment the line listen_addresses = ‘localhost’ and replace localhost with *. With this adjustment, your PostgreSQL on Ubuntu 26.04 server will begin accepting remote connections.

listen_addresses = '*'

Save the file, then exit from the editor. We can edit the pg_hba.conf file now to allow password authentication for your instance.

$ sudo nano /etc/postgresql/17/main/pg_hba.conf

Scroll down and append this line to enable external users to access PostgreSQL on Ubuntu 26.04.

host all all 0.0.0.0/0 md5

Save the file and restart PostgreSQL to apply the changes. Now your system should be configured for remote access.

$ sudo systemctl restart postgresql

We should be able to access the PostgreSQL server from another machine. However, we need to create a password for ‘postgres’ user first.

$ sudo -u postgres psql

In the PostgreSQL shell, run this command so you’ll secure access to PostgreSQL on Ubuntu 26.04 installations.

\password postgres

You will be prompted to type the password for that user, like this, when setting up your system securely.

postgres=# \password postgres
Enter new password for user "postgres": 
Enter it again: 

At this point, you should be able to access the PostgreSQL server remotely and benefit from running PostgreSQL on Ubuntu 26.04 in your network environment.

That’s it!

You have successfully installed the PostgreSQL server on your Ubuntu 26.04 system and can now manage your applications.

Of course, if you are one of our Linux VPS hosting customers, you don’t have to bother with this installation yourself – simply ask our admins, sit back, and relax. Our admins will take care of the installation for you, at no additional cost. Managing a PostgreSQL-based website is not just about the installation; we can help you optimize your PostgreSQL installation if you have an active VPS with us.

If you liked this post, please share it with your friends, or simply leave a comment down below.

Leave a Comment