Help Center/ Virtual Private Cloud/ FAQs/ VPCs and Subnets/ Why Can't I Delete My VPCs and Subnets?
Updated on 2025-08-30 GMT+08:00

Why Can't I Delete My VPCs and Subnets?

Symptom

VPCs and subnets cannot be deleted.

The VPC service has different resources. Some (such as VPCs and subnets) are free, while some are not. For details about VPC resource pricing, see Pricing Details.

Possible Causes

VPCs and subnets provide IP addresses required for network communications. Generally, you can delete a VPC or subnet when no IP address in the VPC or subnet is in use by other resources. You can delete a VPC or subnet if:
  • VPC:
    • The VPC has only subnets that are not in use by other resources, default route tables, and network ACLs. Also, the VPC is not in use by resources, such as subnets that are in use, custom route tables, ECSs, public NAT gateways, private NAT gateways, VPC endpoints, VPC endpoint services, Direct Connect connections, VPC peering connections, VPNs, and enterprise routers.
    • If you want to delete the last VPC in a region:
      • Delete all custom security groups in the region. The default security group does not affect the deletion of VPCs.
      • Release all EIPs in the region.
  • Subnet: No IP address in the subnet is being used by other resources, such as virtual IP addresses, elastic network interfaces, supplementary network interfaces, ECSs, SNAT rules of NAT gateways, VPC endpoints, VPC endpoint services, and load balancers.

If a VPC or subnet cannot be deleted, delete the resources that are using the VPC or subnet as instructed in this section, and try again. If your VPC or subnet still cannot be deleted, submit a service ticket.

Deleting Resources That Are Using a VPC or Subnet

  1. If a VPC or subnet cannot be deleted, record the ID of the resource in the VPC or subnet, and go to the resource console to delete the resource as prompted. Then, delete the VPC or subnet again.
    • VPC: Delete the resources that may use a VPC by referring to Table 1.

      When you delete a VPC, the console may display a message indicating that this is the last VPC in this region and there are custom security groups in this VPC. The system will prompt you to delete the custom security groups. You need to record the security group IDs to delete them.

      Figure 1 Deleting a VPC
    • Subnet: Delete the resources that may use a subnet by referring to Table 2.
      When you delete a subnet, if a message is displayed indicating that the subnet is being used by a cloud server, you need to go to the cloud server console through the link and locate the target cloud server by resource ID.
      Figure 2 Deleting a subnet
    Table 1 Deleting resources in a VPC

    Resource

    Deletion Method

    Security group

    On the VPC security group console, locate the target custom security group and delete it.

    Deleting a Security Group

    EIP

    On the EIP console, locate the target EIP and release it.

    Releasing an EIP

    Custom route table

    On the VPC route table console, locate the target custom route table and delete it.

    Deleting a Route Table

    ECS

    On the ECS console, locate the target ECS and delete it.

    Deleting an ECS

    Public NAT gateway

    On the public NAT gateway console, locate the target public NAT gateway and delete it.

    Deleting a Public NAT Gateway

    Private NAT gateway

    On the private NAT gateway console, locate the target private NAT gateway and delete it.

    Deleting a Private NAT Gateway

    VPC endpoint

    On the VPC endpoint console, locate the target VPC endpoint and delete it.

    Deleting a VPC Endpoint

    VPC endpoint service

    On the VPC endpoint service console, locate the target VPC endpoint service and delete it.

    Deleting a VPC Endpoint Service

    Direct Connect virtual gateway

    On the Direct Connect console, locate the virtual gateway and delete it.

    Deleting a Virtual Gateway

    VPN gateway

    On the VPN console, locate the VPN gateway and delete it.

    Deleting a VPN Gateway

    VPC peering connection

    On the VPC peering connection console, locate the target VPC peering connection and delete it.

    Deleting a VPC Peering Connection

    Enterprise router

    On the enterprise router console, locate the target VPC attachment and delete it.

    Deleting a VPC Attachment

    Table 2 Deleting resources in a subnet

    Resource

    Deletion Method

    Virtual IP address

    On the VPC console, locate the target virtual IP address and release it.

    Releasing a Virtual IP Address

    Elastic network interface

    On the VPC subnet details page, locate the target elastic network interface and delete it.

    Viewing and Deleting Resources in a Subnet

    Supplementary network interface

    On the VPC supplementary network interface console, locate the target supplementary network interface and delete it.

    Deleting a Supplementary Network Interface

    Cloud server

    The cloud server may be an ECS or BMS. You need to locate the cloud server that uses the subnet on the VPC subnet details page and delete it.

    Viewing and Deleting Resources in a Subnet

    SNAT rule of a public NAT gateway

    On the public NAT gateway console, locate the target public NAT gateway and delete the SNAT rule.

    Deleting an SNAT Rule

    SNAT rule of a private NAT gateway

    On the private NAT gateway console, locate the target private NAT gateway and delete the SNAT rule.

    Deleting an SNAT Rule

    VPC endpoint

    On the VPC endpoint console, locate the target VPC endpoint and delete it.

    Deleting a VPC Endpoint

    VPC endpoint service

    On the VPC endpoint service console, locate the target VPC endpoint service and delete it.

    Deleting a VPC Endpoint Service

    Load balancer

    On the VPC subnet details page, locate the target load balancer and delete it.

    Viewing and Deleting Resources in a Subnet

  2. If you cannot be redirected to the target resource, use the resource ID to view and search for the target resource on the resource overview page. For details, see Searching for Cloud Resources.