Install PostgreSQL on Ubuntu 26.04 LTS
Install PostgreSQL on Ubuntu 26.04 LTS, create an application role and database, or choose a major version from PGDG; verify the service and connect with psql.
On this page
Ubuntu 26.04 LTS (Resolute Raccoon) was released on April 23, 2026. Ubuntu includes PostgreSQL packages in its own repository. If you need to choose a specific PostgreSQL major version, the PostgreSQL project’s APT repository is another option. See the Ubuntu release list and the PostgreSQL project’s Ubuntu installation instructions for current platform support.
If PostgreSQL is already installed and contains data, make a verified backup before installing another major version. A new package does not upgrade an existing database cluster; follow our PostgreSQL 17 to 18 upgrade guide and PostgreSQL’s major version upgrade instructions when you need to move existing data.
Prerequisites
Before you begin, make sure you have:
- Ubuntu 26.04 LTS with internet access.
- A user account with
sudoprivileges. - A terminal and basic familiarity with Linux commands.
Install the Ubuntu Package
Ubuntu’s postgresql package installs the major version selected for Ubuntu 26.04. This is the simplest option when you do not need to choose a particular major version.
Refresh APT’s package index, check the candidate, and install PostgreSQL:
sudo apt update
apt-cache policy postgresql
sudo apt install postgresql
Ubuntu maintains the selected PostgreSQL package during the release’s support lifetime. The exact version is shown by apt-cache policy postgresql and may change as Ubuntu publishes updates.
Install PostgreSQL 18 from the PostgreSQL APT Repository
Use the PostgreSQL project’s repository when you want to select a specific major version. Its official Ubuntu instructions list Ubuntu 26.04 (resolute) as supported and provide the postgresql-18 package. For LTS releases, the repository supports amd64, arm64, and ppc64el architectures.
Install the repository setup package and run its configuration script:
sudo apt update
sudo apt install -y postgresql-common
sudo /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh
Refresh the package index and check that APT can see PostgreSQL 18 before installing it:
sudo apt update
apt-cache policy postgresql-18
The candidate should come from the PostgreSQL APT repository. Install the versioned server package:
sudo apt install postgresql-18
The versioned package keeps the server on major version 18 while receiving package updates within that major version. Use the project’s Ubuntu installation instructions if you want to select another supported major version or configure the APT source manually.
Verify the Installation
Check the client version and service status:
psql --version
sudo systemctl status postgresql --no-pager
Ask the server for its version:
sudo -u postgres psql -c 'SELECT version();'
Create an Application Role and Database
Open an interactive session as PostgreSQL’s administrative postgres account:
sudo -u postgres psql
Create a login role, set its password with \password so the password is not written in the SQL command or shell history, and create a database owned by that role:
CREATE ROLE app_user LOGIN;
\password app_user
CREATE DATABASE appdb OWNER app_user;
\q
Connect as the application role and verify the database and user:
psql -h localhost -U app_user -d appdb -W
At the psql prompt, run:
SELECT current_database(), current_user;
The -W option prompts for the role password. Keep the database bound to local access unless remote clients need to connect; configure authentication and firewall rules for the intended hosts before opening network access.
Manage the PostgreSQL Service
Use systemctl to manage PostgreSQL:
sudo systemctl start postgresql
sudo systemctl stop postgresql
sudo systemctl restart postgresql
sudo systemctl status postgresql --no-pager
To enable the service at boot, run:
sudo systemctl enable postgresql
Troubleshooting
- If
psqlcannot connect, checksudo systemctl status postgresqland review recent service logs withsudo journalctl -u postgresql -e --no-pager. - Ubuntu can run multiple PostgreSQL clusters or major versions. Use
pg_lsclustersto see the installed clusters, versions, ports, and status; connect to the intended cluster and port. - If
apt-cache policy postgresql-18has no candidate after adding the PostgreSQL APT repository, runsudo apt updateand confirm the setup script configured theresolute-pgdgsource.
Conclusion
Ubuntu’s postgresql package installs the version selected and maintained for Ubuntu 26.04. If you need to choose a major version, the PostgreSQL project’s APT repository supports Resolute and provides versioned packages such as postgresql-18.
For Debian 13 (Trixie), see our PostgreSQL installation guide for Debian 13. For an older LTS release, see our PostgreSQL installation guide for Ubuntu 22.04. For more database material, visit our PostgreSQL tutorials and PostgreSQL Reference.