You need to enable JavaScript to run this app.
Elastic Compute Service

Elastic Compute Service

Copy page
Download PDF
VPC
Changing VPC or subnet
Copy page
Download PDF
Changing VPC or subnet
This topic introduces how to change the VPC or subnet for an ECS instance.​
warning​
Networks are isolated between different VPCs. Therefore, after you change the VPC for the instance, the instance can not communicate with the instances in the original VPC. Please proceed with caution. How to connect networks between different VPCs?​
Applicable scenarios​
  • As the business grows, the existing network architecture can no longer meet business needs, which requires new network plans. If multiple businesses share one VPC, management difficulties may occur. Therefore, you can plan new VPCs based on your needs and then migrate corresponding ECS instances to the VPCs.​
  • If address conflicts occur when you enable communication of ECS instances between different VPCs, you can change the VPC or subnet of the ECS instance.​
  • If you select an inappropriate VPC or subnet when creating an ECS instance, you can change the VPC or subnet for the instance.​
Prerequisites​
​
Resource​
Prerequisites​
Description​
ECS instance​
Must be in the Stopped state​
If the instance is not in the Stopped state, stop the instance first.​
​
When you replace instance VPCs or subnets in a batch, all selected instances must be under the same project and in the same availability zone.​
-​
​
Not added to CLB backend server group​
If the ECS instance was added to a CLB backend server, remove the instance from the backend server group first.​
​
Not used by other cloud services​
-​
​
Not associated with High-Availability Virtual IP Address​
If an Anycast EIP has been associated, disassociate the Anycast EIP. The High-Availability Virtual IP Address is in Beta. If you need a trial, please contact the account manager.​
​
The associated subnet is not attached to a custom route table​
If the associated subnet was attached to a custom route table, detach the subnet to the custom route table.​
​
No secondary network interface is mounted​
If a secondary network interface was mounted, unmount the secondary network interface from the selected instance.​
​
The associated primary network interface has not been allocated a secondary private IP address​
If a secondary private IP address was allocated, release the secondary private IP address.​
​
Not associated with an IPv6 address​
If an IPv6 address was allocated to the instance, release the IPv6 address first. The feature of allocating IPv6 addresses to ECS instances is currently in Beta. If you need a trial, please contact the account manager.​
​
Not associated with Anycast EIP​
If an Anycast EIP has been associated, disassociate the Anycast EIP. Anycast EIP is currently in Beta. If you need a trial, please contact the account manager.​
VPC or subnet​
The target VPC and instance are in the same region​
If the target VPC and selected instance are not in the same region, create a VPC in the same region as the instance.​
​
The target subnet and current subnet are in the same availability zone​
If the current subnet and target subnet are not in the same availability zone, create a subnet in the same availability zone as the current subnet.​
​
Procedure​
Replace the VPC or subnet of one instance​
warning​
The target instance must be in the Stopped state.​
  1. Log in to the ECS console. ​
  1. In the left-side navigation pane, select "Instances & Images > Instances".​
  1. In the top menu bar, select the target project and region.​
  1. On the Instances page, select "··· > Network and security group > Modify VPC" in the "Actions" column on the right of the target instance.​
  1. Refer to the table below to configure the relevant parameters.​
  • ​
    Parameter​​
    Description​
    Sample value​
    Target VPC​
    Select a VPC in the same region.​
    tip​
    If you only need the subnet replaced, select the current VPC of the ECS instance.​
    des-vpc​
    Subnet​
    Select a subnet in the same availability zone as the subnet of the current instance, and then assign an IP address for the selected subnet. You can choose to have the system automatically assign an IP address or manually assign an IP address.​
    des-subnet​
    Target security group​
    Select a security group.​
    des-sg​
    ​
  1. Click "Save" to complete the operation.​
Replace instance VPCs or subnets in a batch​
warning​
When you replace instance VPCs or subnets in a batch, the selected instances must be under the same project and in the same availability zone.​
  1. Log in to the ECS console.​
  1. In the top menu bar, select the target project and region.​
  1. In the left-side navigation pane, select "Instances & Images > Instances".​
  1. Select one or more instances, and then select "··· > Modify VPC" at the bottom of the list.​
  1. The system pops up a "In bulk Modify VPC" window. Here, you can view operable instances, inoperable instances, and the reasons.​
Inoperable instances are instances that do not meet the conditions required for modifying VPCs. You can address the issue based on prompts and try again once the conditions are met.​
  1. Click the "Continue" button to go to the Modify VPC page and configure relative parameters.​
  • ​
    Parameters​
    Description​
    Sample value​
    Target VPC​
    Select a VPC in the same region.​
    tip​
    If you only need the subnet replaced, select the current VPC of the ECS instance.​
    des-vpc​
    Subnet​
    Select a subnet in the same availability zone as the subnet of the current instance, and then assign an IP address for the selected subnet. You can choose to have the system automatically assign an IP address or manually assign an IP address.​
    des-subnet​
    Target security group​
    Select a security group.​
    des-sg​
    ​
  1. Click "Reboot" to complete the operation.​
Operation result​
  • After you replace instance VPCs or subnets in a batch, the instances are still in the Stopped state. You need to manually start the ECS instances.​
  • To view the changed VPC or subnet, go to the Overview page by clicking the instance name on the Instances page.​
Related document​
Last updated: 2026.06.18 19:52:58