When you switch business traffic from one ApsaraDB RDS for PostgreSQL instance to another — for example, after a version upgrade or disaster recovery — you need the new instance to receive connections without requiring application changes. The endpoint exchange feature lets you swap the endpoints of two instances in a single operation, so your application continues connecting to the same address while traffic shifts to the new instance.
Prerequisites
Before you begin, make sure both instances meet all of the following conditions:
Both instances are in the Running state.
Both instances belong to the same Alibaba Cloud account.
The billing method of each instance is pay-as-you-go or subscription.
Both instances use the same port.
The connection pool (PgBouncer) feature is disabled on both instances.
Babelfish is disabled on both instances — the minor version of each instance must not contain
babelfish.
Constraints
Endpoint type pairing
Only endpoints of the same type can be exchanged:
| Source endpoint type | Target endpoint type |
|---|---|
| Internal endpoint | Internal endpoint |
| Public endpoint | Public endpoint |
IP whitelists
IP whitelists are not exchanged along with the endpoints. If you do not synchronize the IP whitelists before the exchange, clients that were allowed to access one instance may lose access after the swap. Manually synchronize the IP whitelists between the two instances before proceeding.
Post-exchange read-only state
After the exchange, the source instance enters read-only status to protect data consistency. Use the instance that will stop receiving business traffic as the source, and the instance taking over traffic as the target.
To remove the read-only state from the source instance, set itsrds_force_trans_ro_non_supparameter tooff. Validate your business thoroughly before doing this.
Virtual IP address (VIP)
Retaining the virtual IP address (VIP) can cause DNS cache issues and extend the exchange time.
Exchange instance endpoints
Go to the Instances page. In the top navigation bar, select the region of the source instance, then click the instance ID.
In the left-side navigation pane, click Database Connection.
On the Database Connection page, click Link exchange address.

In the dialog box, configure the following settings, then click OK:
Setting Description Switch Network Type Select the network type to exchange, if needed. Target Instance Name Select the target instance. Do you want to keep vip Choose whether to retain the virtual IP address (VIP). The system automatically fills in Exchange this instance link address and Target link address based on your selection.
After the exchange completes, the source instance's endpoint now points to the target instance, and the target instance's endpoint points to the source instance. The source instance enters read-only status.
API reference
To exchange endpoints using the API, call ModifyDBInstanceConnectionString with the TargetDBInstanceId and RetainVip parameters.