Install PostgreSQL on Ubuntu 26.04 LTS
Install PostgreSQL on Ubuntu 26.04 LTS with apt, verify the service, create an application role and database, or choose a major version from PGDG.
On this page
Ubuntu 26.04 LTS includes PostgreSQL packages in its standard repositories. The postgresql package installs the PostgreSQL version selected for this Ubuntu release. If you need a particular supported major version, you can use the PostgreSQL Global Development Group (PGDG) Apt Repository instead. See the PostgreSQL project’s Ubuntu installation instructions.
Install the Ubuntu package
Refresh the Apt package index, then install PostgreSQL:
sudo apt update
sudo apt install postgresql
Check the client version and database service:
psql --version
sudo systemctl status postgresql --no-pager
Ubuntu’s package sets up the postgres administrative role. Use it to verify that the server responds:
sudo -u postgres psql -c 'SELECT version();'
Create an application role and database
Open an interactive session as the PostgreSQL administrator:
sudo -u postgres psql
Create a login role, set its password using \password so the password is not included 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 confirm 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.
Install a specific PostgreSQL major version from PGDG
Ubuntu’s repository version can lag the newest PostgreSQL major. The PGDG repository supports Ubuntu 26.04 (resolute) and provides multiple PostgreSQL versions. To install PostgreSQL 18 from PGDG, configure the repository and install its versioned package:
sudo apt install -y postgresql-common
sudo /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh
sudo apt update
sudo apt install postgresql-18
The setup script configures the PGDG repository for the detected Ubuntu release. The PostgreSQL Apt Repository page lists supported Ubuntu releases and packages. Replace 18 with a supported major version only when your application requires it; review the upgrade notes before moving an existing database to another major version.
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. Check the installed clusters with
pg_lsclustersand connect to the intended port and cluster. - For more details about Ubuntu 26.04 support, see the official release notes.