How do you upgrade RDS PostgreSQL to a new major version safely?
By the Keel team · Last checked · 5 min read
Short answer
Rehearse on a restored copy first, then cut over with an RDS Blue/Green Deployment. AWS says switchover downtime is typically under one minute, while an in-place upgrade can leave the database unavailable for several minutes or more. Blue/green wins when downtime matters; in-place is simpler when a short maintenance window is fine.
Under 1 minute
Typical blue/green switchover downtime, per AWS
Source: AWS docs, Nov 2026
300 seconds
Default switchover timeout before RDS rolls back
Source: AWS docs, Nov 2026
How do you upgrade RDS PostgreSQL to a new major version safely?
Check compatibility, rehearse on a restored copy, then upgrade in place in a planned window or use a blue/green deployment.
Check compatibility, rehearse on a restored copy, then either upgrade in place in a planned window or use a blue/green deployment to switch over with a short pause. Major upgrades are never automatic: you start them by modifying the instance.
- Check the target version, instance class, extensions and parameter group family.
- Restore a recent snapshot to a test instance, upgrade it and run your app and tests against it.
- Time the rehearsal and write down the fallback.
- Choose in-place or blue/green, as described below.
- Upgrade or switch over in a quiet period.
- Run
ANALYZEon every database and update extensions. - Keep the old environment briefly, then remove it.
What should you check before you start?
The upgrade fails on a handful of known blockers, so find them on a copy first.
The upgrade fails on a handful of known blockers, so find them on a copy first. AWS lists the checks in its major version upgrade process, and each can stop the upgrade outright.
- A custom parameter group: use a default for the target version or create a custom one for it.
- An instance class that does not support the target version.
- Open prepared transactions, which must be committed or rolled back.
- Unsupported
reg*data types in user tables, other thanregtypeandregclass. - Logical replication slots: the upgrade fails if any exist, and they are often used by AWS DMS or data pipelines, so confirm what each does before dropping it.
- Extensions unsupported on the target version, which must be dropped first.
- Read replicas: in-Region replicas are upgraded with the primary and add to the outage.
If the precheck fails, RDS writes pg_upgrade_precheck.log, which names what to fix. To list valid targets for your version:
aws rds describe-db-engine-versions \
--engine postgres \
--engine-version 16.1 \
--query 'DBEngineVersions[*].ValidUpgradeTarget[*].{EngineVersion:EngineVersion}' \
--output textIn-place or blue/green: which should a small team choose?
Choose blue/green when you cannot accept several minutes of downtime; choose in-place when a planned window is acceptable.
Choose blue/green when you cannot accept several minutes of downtime or want a rehearsal environment and an untouched original to fall back on. Choose in-place when a planned window is acceptable, the database is small and you want the fewest moving parts.
| In-place upgrade | Blue/green deployment | |
|---|---|---|
| Downtime | Database might be unavailable for several minutes or more | Switchover typically under one minute, longer depending on workload |
| How it works | RDS runs pg_upgrade on the instance | RDS copies production to a synced green copy, you upgrade green, then switch |
| Rehearsal | On a separate restored copy | Green is a production-like copy you can test before any traffic |
| Extra cost | None beyond a test instance | You run both environments while the deployment exists |
| Going back | Restore the pre-upgrade snapshot to a new database | Blue is kept, but replication stops after switchover |
Both need the rehearsal first. Blue/green does not remove the need to test your app against the new version.
How do you run a blue/green upgrade?
Create the deployment with the target version, validate green while it stays read-only, then switch over in a quiet period.
Create the deployment with the target engine version and a parameter group for the new family, validate green while it stays read-only, then switch over in a quiet period. RDS copies the topology and keeps green in sync, and names the copies with a -green- suffix.
aws rds create-blue-green-deployment \
--blue-green-deployment-name my-prod-db-upgrade \
--source arn:aws:rds:eu-west-2:123456789012:db:my-prod-db \
--target-engine-version <target-version> \
--target-db-parameter-group-name <new-family-parameter-group>
aws rds switchover-blue-green-deployment \
--blue-green-deployment-identifier bgd-1234567890abcdef \
--switchover-timeout 600Keep green read-only while testing, because writes on green can cause replication conflicts and unintended data in production. Read the prerequisites for your engine version on AWS's blue/green pages before creating one.
What does the cutover look like for users?
Most users see a short pause while connections drop and reconnect.
Most users see a short pause while connections drop and reconnect. During switchover RDS stops new writes, drops existing connections, waits for green to catch up, renames the instances and endpoints, then allows writes on the new primary.
AWS sets the switchover timeout between 30 and 3,600 seconds, with a default of 300, and rolls everything back if it overruns, leaving both environments unmodified. Guardrails also block a switchover that would cause long downtime or data loss.
- Keep the DNS cache time to live at five seconds or less, or applications may keep writing to the old environment.
- Switch in low traffic, since long transactions and DDL increase downtime.
- Check that replica lag is near zero first.
- Make sure your app retries connections.
What if the upgrade goes wrong?
Decide the fallback before you start, because going back is different before and after cutover.
Decide the fallback before you start, because going back is different before and after cutover. Before switchover you delete green and try again. After it, RDS does not give you an easy way back.
- Before switchover: delete the green environment. Production was never touched.
- After switchover: the old blue instance is kept and renamed with an
-old1suffix, and standard charges apply, but replication stops, so writes made on the new primary are not on it. AWS's documentation does not describe switching back. - In-place: if the backup retention period is above 0, RDS takes a snapshot before and after the upgrade. You cannot revert in place; you restore the pre-upgrade snapshot to a new database.
- Point-in-time restore is unavailable during the upgrade itself.
That is why the rehearsal matters: most problems show up there. Testing an RDS restore step by step covers building the scratch copy.
What do you do after the upgrade?
Run ANALYZE on every database, update extensions and test the app with a representative workload.
Run ANALYZE on every database, update extensions and test the app with a representative workload. A major upgrade does not transfer optimiser statistics or upgrade extensions, so queries can slow down until you do.
ANALYZE VERBOSE;
ALTER EXTENSION pg_stat_statements UPDATE;Then delete the test instance, the old blue environment once you are sure, and any read replicas you removed beforehand need recreating. Schedule patching so the next change is not a surprise: how often to patch AWS production and zero-downtime Postgres migrations cover the routine around it.
Are you ready to upgrade?
Tick each item that is true today.
- You rehearsed the upgrade on a restored copy and timed it.
- Extensions, replication slots and parameter groups are checked.
- A recent snapshot exists and you know which restore is your fallback.
- The app retries connections and DNS caching is short.
- You will run ANALYZE and extension updates straight after.
Decision point: Five ticks: you can upgrade with a clear head. Three or fewer: rehearse on a copy before touching production.
Sources
- AWS docs, Upgrading the PostgreSQL DB engine for Amazon RDS (checked November 2026)
- AWS docs, How to perform a major version upgrade (RDS for PostgreSQL) (checked November 2026)
- AWS docs, Overview of Amazon RDS Blue/Green Deployments (checked November 2026)
- AWS docs, Switching a blue/green deployment (checked November 2026)
Keep reading
Keel is an AWS release and recovery operations service for SaaS teams of 3 to 15 developers, provided by Bargainn Services Ltd, a UK company registered at Companies House (16497746). Registered office: 3rd Floor, 86-90 Paul Street, London, EC2A 4NE, United Kingdom.