---
title: "Upgrade to a New PostgreSQL Major Version"
description: "Upgrade a Managed PostgreSQL service to a newer major version in place from the Portal or the Exoscale API, after a compatibility check."
url: https://community.exoscale.com/product/dbaas/service-specific/postgresql/how-to/upgrade-major-version/
product: "PostgreSQL"
section: product
last_updated: 2026-11-24
---
> For AI agents: the documentation index is at https://community.exoscale.com/llms.txt. Every page is available as markdown at `<page URL>index.md` or with `Accept: text/markdown`.

# Upgrade to a New PostgreSQL Major Version

A major version upgrade moves a Managed PostgreSQL service to a newer PostgreSQL version in place. The service keeps its hostname, data and users. The upgrade cannot be reverted, so prepare a way back first.

You can upgrade from the [Portal](#upgrade-from-the-portal) or with the API. The
`exo dbaas update` command has no flag to change the major version.

## Before You Upgrade

### Apply Pending Maintenance Updates

The upgrade cannot start while maintenance updates are pending on the service. Apply them first
from the `maintenance` tab of the service in the Portal, or with
`exo api start-dbaas-pg-maintenance SERVICE_NAME -z ZONE`, see
[Manage Maintenance Windows](https://community.exoscale.com/product/dbaas/how-to/maintenance-windows/index.md).

### Keep a Way Back

After the upgrade, `exo dbaas show SERVICE_NAME -z ZONE --backups` lists only the backup taken at
the end of the upgrade, so you cannot fork the service back to a moment before it. Keep one of
these until the upgraded service is validated:

- A [fork](https://community.exoscale.com/product/dbaas/how-to/backups-restore/index.md#forks) of the service, which stays on the old
  version.
- A logical dump taken with `pg_dump`.

Rehearse on the fork: upgrade it, run your application tests against it, and time the upgrade on
your real data volume. You can go directly to a version several majors ahead, up to PostgreSQL 18:
version 19 is available for new services, but the upgrade does not accept it as a target yet.
Prefer the default version, unless an extension or your application needs another one. Read the
[PostgreSQL release notes](https://www.postgresql.org/docs/release/) of every major version between
the current one and the target.

### Check the Extensions

Connect to each database with `psql` and list its extensions:

```sql
SELECT extname, extversion FROM pg_extension ORDER BY extname;
```

The compatibility check detects an extension whose library is missing on the target version.
Extensions with their own version matrix, such as `postgis` and `timescaledb`, also have release
notes to read.

### Check Logical Replication

If the service uses logical replication and runs PostgreSQL 16 or earlier, the upgrade loses the
replication state. `pg_upgrade` keeps logical replication slots and subscriptions only from
PostgreSQL 17 on, see the
[PostgreSQL documentation](https://www.postgresql.org/docs/current/logical-replication-upgrade.html).
On a publisher, the slots are gone and the subscribers stop receiving changes. On a subscriber, each
subscription comes back disabled. Plan to drop and re-create the subscriptions, with a new initial
copy, after the upgrade.

## Upgrade from the Portal

1. Open the service in the [Portal](https://portal.exoscale.com/).
2. In the menu at the top right of the service page, select **Upgrade**.
3. Select the target version. The Portal runs the compatibility check and shows the result.
4. If the upgrade is possible, select **Upgrade**. If it is not, the button stays disabled: fix
   what the result reports, or choose another target version.

The upgrade starts as soon as you confirm, see [Apply the Upgrade](#apply-the-upgrade) for what to
expect. The action is unavailable while another operation runs on the service. For a read replica,
upgrade its primary service instead.

## Upgrade with the API

### Run the Compatibility Check

```bash
echo '{"target-version":"TARGET_VERSION"}' | \
  exo api create-dbaas-pg-upgrade-check SERVICE_NAME -z ZONE
```

Parameters:

- `TARGET_VERSION`: the target major version, as a string, for example `"18"`.
- `SERVICE_NAME`: name of the Managed PostgreSQL service, for example `my-postgresql`.
- `ZONE`: zone the service runs in, for example `ch-gva-2`.

The check runs `pg_upgrade --check` against the service and answers within seconds. When the
upgrade can proceed, the answer contains `"success": true`. When it cannot, `success` is `false`
and `result` holds the `pg_upgrade` output, which names the problem and the database. Read
`result` for the cause, as `result-codes` can hold only a generic code.

### Apply the Upgrade

```bash
echo '{"version":"TARGET_VERSION"}' | \
  exo api update-dbaas-service-pg SERVICE_NAME -z ZONE
```

Use the version that passed the check. The platform starts the upgrade only if the latest check on
the service passed for that version.

> [!WARNING]
> The upgrade starts as soon as the request is accepted, outside the maintenance window. Open
> sessions end, and new connections fail while PostgreSQL restarts on the new version, which takes
> a few seconds on a small single-node service. On a plan with standby nodes, the standbys are
> removed before the upgrade and rebuilt after it: connections fail for up to about a minute, and
> the service has no standby until the new ones are synchronized. Make sure your application
> reconnects.

The `Version` row of `exo dbaas show SERVICE_NAME -z ZONE` then shows the new version.

## After the Upgrade

The hostname, port, IP filter, users, databases, connection pools, settings and maintenance window
stay the same. Check these points:

- **Planner statistics.** The upgrade does not carry them over, so queries can be slow at first.
  The platform then analyzes every table; on a small service, this takes about a minute and a
  half. If `last_analyze` in `pg_stat_user_tables` is still empty for some tables, run `ANALYZE;`
  in each database.
- **Extensions.** Some extensions move to a newer version. List those behind what the new version
  offers, then run `ALTER EXTENSION EXTENSION_NAME UPDATE;` for each:

  ```sql
  SELECT e.extname, e.extversion AS installed, a.default_version AS available
  FROM pg_extension e
  JOIN pg_available_extensions a ON a.name = e.extname
  WHERE e.extversion IS DISTINCT FROM a.default_version;
  ```

- **Statistics and backups.** Cumulative statistics, such as the counters of
  `pg_stat_statements`, start again from zero. A new base backup is taken at the end of the
  upgrade.
- **Read replicas and Terraform.** Read replicas are upgraded after the upgrade finishes on the
  primary. Check that each replica runs the new version, see
  [Create Read Replicas](https://community.exoscale.com/product/dbaas/service-specific/postgresql/how-to/read-replicas/index.md). If
  Terraform manages the service, set `pg.version` to the new major version before the next apply,
  see [Use Terraform for DBaaS](https://community.exoscale.com/product/dbaas/how-to/terraform/index.md).

## Troubleshooting

| Symptom | Cause | Fix |
| --- | --- | --- |
| The check fails with `Cannot perform upgrade with pending maintenance updates` | Maintenance updates are pending on the service. | Apply them, see [Apply Pending Maintenance Updates](#apply-pending-maintenance-updates), then run the check again. |
| `Invalid value ... at 'target-version'` | The target version is not accepted by the upgrade. The message lists the accepted versions. | Choose one of the listed versions. |
| The check fails with `could not load library "$libdir/postgis-3.3"` and `result-codes` holds only `pg.upgrade_check.error.unknown` | An extension version installed on the service has no library on the target version. | Fix what `result` reports, or choose another target version, then run the check again. |
| `Upgrade check result missing, please run upgrade_check task` | The latest check on the service did not pass for this version. | Run the check again for the version you want, then apply. |
| Subscriptions stop replicating after the upgrade | The service ran PostgreSQL 16 or earlier and used logical replication. | Drop and re-create the subscriptions, see [Check Logical Replication](#check-logical-replication). |

## Related Pages

- [PostgreSQL Version Lifecycle](https://community.exoscale.com/product/dbaas/service-specific/postgresql/reference/version-lifecycle/index.md)
- [Manage Backups and Restores](https://community.exoscale.com/product/dbaas/how-to/backups-restore/index.md)
- [JSON Configuration](https://community.exoscale.com/product/dbaas/service-specific/postgresql/how-to/json-configuration/index.md)
- [Manage Maintenance Windows](https://community.exoscale.com/product/dbaas/how-to/maintenance-windows/index.md)

