Upgrade PostgreSQL from 17 to 18 on Ubuntu 26.04
Title: Upgrade PostgreSQL from 17 to 18 on Ubuntu 26.04
Published Time: 2026-05-24T00:00:00+02:00
Markdown Content: Howto guide for upgrading PostgreSQL from version 17 to 18 on Ubuntu, after its upgrade from version 25.10 (Questing Quokka) to 26.04 (Resolute Raccoon).
© 2026 Paolo Melchiorre CC BY-SA “View of the Tirino river, nearby Capestrano, L'Aquila, Italy”
Upgrade PostgreSQL on Ubuntu (10 part series) 1. Upgrade PostgreSQL from 9.5 to 9.6 on Ubuntu 17.04 2. Upgrade PostgreSQL from 9.6 to 10 on Ubuntu 18.04 3. Upgrade PostgreSQL from 10 to 11 on Ubuntu 19.04 4. Upgrade PostgreSQL from 11 to 12 on Ubuntu 20.04 5. Upgrade PostgreSQL from 12 to 13 on Ubuntu 21.04 6. Upgrade PostgreSQL from 13 to 14 on Ubuntu 22.04 7. Upgrade PostgreSQL from 14 to 15 on Ubuntu 23.04 8. Upgrade PostgreSQL from 15 to 16 on Ubuntu 24.04 9. Upgrade PostgreSQL from 16 to 17 on Ubuntu 25.04 10. Upgrade PostgreSQL from 17 to 18 on Ubuntu 26.04
TL;DR
After upgrade Ubuntu from version 25.10 (Questing Quokka) to 26.04 (Resolute Raccoon):
$ sudo pg_upgradecluster 17 main -v 18
$ sudo pg_dropcluster 17 main
Goal
This article is aimed at those like me who use Ubuntu and PostgreSQL to develop locally on their computer and after the last update to Ubuntu 26.04 they have two versions of PostgreSQL installed.
Upgrade PostgreSQL
During Ubuntu updgrade to 26.04 you receive this message:
Configuring postgresql
The PostgreSQL database cluster
17/maincan be upgraded to version18, this will be attempted now. (If no automated cluster upgrades are desired, uninstall the“postgresql” meta package.)Alternatively, the cluster can later be upgraded by running the command:
pg_upgradecluster 17 main -v 18Once the upgraded cluster has been validated to work, drop the old cluster using the command:
pg_dropcluster 17 mainUpgrade PostgreSQL cluster
17/mainto18?
If you selected <No> during the installation, now you can upgrade your PostgreSQL cluster following the next steps.
Use dpkg -l | grep postgresql to check which versions of postgres are installed:
ii postgresql 18+290ubuntu1 all …
ii postgresql-17 17.10-0ubuntu0.25.10.1 amd64 …
ii postgresql-18 18.4-0ubuntu0.26.04.1 amd64 …
ii postgresql-18-jit 18.4-0ubuntu0.26.04.1 amd64 …
ii postgresql-client-17 17.10-0ubuntu0.25.10.1 amd64 …
ii postgresql-client-18 18.4-0ubuntu0.26.04.1 amd64 …
ii postgresql-client-common 290ubuntu1 all …
ii postgresql-common 290ubuntu1 all …
Run pg_lsclusters, your 17 main cluster should be listed.
Ver Cluster Port Status Owner Data directory Log file
17 main 5432 online postgres /var/lib/postgresql/17/main …
Upgrade the 17 cluster to the latest version.
$ sudo pg_upgradecluster 17 main -v 18
Your 18 cluster should now be also listed and you can verifity running pg_lsclusters
Ver Cluster Port Status Owner Data directory Log file
17 main 5433 down postgres /var/lib/postgresql/17/main …
18 main 5432 online postgres /var/lib/postgresql/18/main …
Check that the upgraded cluster works, then remove the 17 cluster.
$ sudo pg_dropcluster 17 main
After all your data check you can remove your old packages.
$ sudo apt purge \
postgresql-17 \
postgresql-client-17
Disclaimer
There is no warranty for the program, to the extent permitted by applicable law. Except when otherwise stated in writing the copyright holders and/or other parties provide the program “as is” without warranty of any kind, either expressed or implied, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose. The entire risk as to the quality and performance of the program is with you. Should the program prove defective, you assume the cost of all necessary servicing, repair or correction.