All Products
Search
Document Center

ApsaraDB RDS:How do I connect an ECS instance and an ApsaraDB RDS instance over an internal network if these instances reside in networks of different types?

Last Updated:Mar 30, 2026

ECS and RDS can communicate over an internal network only when both instances are in the same network type. If the network types differ — or if both are in Virtual Private Clouds (VPCs) but different ones — use one of the solutions below based on your scenario.

Identify your scenario

ScenarioECS network typeRDS network type
Scenario 1VPCClassic network
Scenario 2Classic networkVPC
Scenario 3VPCVPC (different VPC)
Scenario 4VPCVPC (same VPC, still failing)

Scenario 1: ECS in VPC, RDS in classic network

Choose one of the following solutions. Method 1 is recommended.

Method 1: Migrate RDS to the VPC where ECS resides

Migrate the RDS instance from the classic network to the same VPC as the ECS instance. For details, see Change the network type.

Method 2: Purchase an ECS instance in the classic network

Purchase a new ECS instance in the classic network. VPCs provide higher security than the classic network — use this method only if migrating the RDS instance is not feasible.

Method 3: Connect via the RDS public endpoint

Connect the ECS instance to the RDS instance using the RDS public endpoint. This method has poor performance, security, and stability. Apply for a public endpoint for your database engine:

ECS instances cannot be migrated from a VPC to the classic network.

Scenario 2: ECS in classic network, RDS in VPC

Choose one of the following solutions. Method 1 is recommended.

Method 1: Migrate ECS to the VPC where RDS resides

Migrate the ECS instance from the classic network to the same VPC as the RDS instance. To find the VPC ID of the RDS instance, click View Details to the right of the Network Type parameter on the RDS instance details page. For migration steps, see Migrate an ECS instance.

Method 2: Change the RDS network type to classic network

Change the RDS instance network type from VPC to classic network. VPCs provide higher security — use this method only if migrating the ECS instance is not feasible.

Method 3: Use ClassicLink

Use the ClassicLink feature to connect the classic-network ECS instance to the VPC-based RDS instance over an internal network. For details, see Enable ClassicLink.

If the connection still fails after enabling ClassicLink, see Troubleshoot connection issues between a classic network and a VPC after you establish a ClassicLink connection.

Method 4: Connect via the RDS public endpoint

Connect using the RDS public endpoint. This method has poor performance, security, and stability. Apply for a public endpoint for your database engine:

Scenario 3: ECS and RDS in different VPCs

Both instances are in VPCs but in different VPCs. Choose one of the following solutions. Method 1 is recommended.

Method 1: Migrate RDS to the VPC where ECS resides

Change the VPC and vSwitch of the RDS instance so it resides in the same VPC as the ECS instance. For details, see Change the VPC and vSwitch.

Method 2: Connect the two VPCs using Cloud Enterprise Network (CEN)

Create a Cloud Enterprise Network (CEN) instance to connect the two VPCs. For details, see Use CEN to enable intra-region network communication.

Method 3: Connect via the RDS public endpoint

Connect using the RDS public endpoint. This method has poor performance, security, and stability. Apply for a public endpoint for your database engine:

Scenario 4: Same VPC, still cannot connect

If the ECS and RDS instances are in the same VPC and the same region, but the ECS instance can reach the RDS public endpoint while the internal endpoint is unreachable (both ping and telnet fail), the issue is likely caused by routing problems. See What do I do if an ECS instance cannot connect to an ApsaraDB RDS instance due to routing problems?