Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Servers, nginx and Docker

AWS will not delete your VPC because a network interface is still there

ErrorDelete VPC lists resources you must delete or terminate first

Short answer

A VPC cannot be deleted while a requester-managed network interface exists in it. An AWS service owns that interface, so you cannot detach or delete it by hand. Find the owner in the interface description, delete that resource (NAT gateway, load balancer, endpoint, RDS), then delete the VPC.

  • Applies to AWS Console, AWS CLI v2
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    List the network interfaces that an AWS service created on your behalf. The Description column names the owner.

    aws ec2 describe-network-interfaces \
      --filters "Name=requester-managed,Values=true" \
      --query "NetworkInterfaces[*].[Description, InterfaceType]" \
      --output table
  2. 2Match what you see, then jump to its fix

    1. 1Description such as VPC Endpoint Interface, or a NAT gateway, load balancer or RDS nameA requester-managed interface belongs to a service that still existsFix
    2. 2The interface is no longer in use but is still listedAn interface was left behind, detached, after its service was deletedFix
    3. 3The console lists resources you must delete or terminate before the VPC can goInstances and gateways still exist in the VPCFix

What does the error look like?

  • Delete VPC lists resources you must delete or terminate first
  • A network interface owned by an AWS service cannot be detached or modified by you

Cause 1 of 3

A requester-managed interface belongs to a service that still exists

1Check

Requester-managed interfaces are created by an AWS service, for example a DB instance from RDS, a NAT gateway or an interface endpoint. You cannot detach or modify them yourself.

aws ec2 describe-network-interfaces --filters "Name=requester-managed,Values=true" --query "NetworkInterfaces[*].[NetworkInterfaceId, Description]" --output table

2Fix

Delete or terminate the resource the description points to. The service then detaches and deletes its interface for you.

# Delete the resource named in the Description: the NAT gateway, load balancer,
# interface endpoint or DB instance, in that service's own console or CLI.

3Verify

The interface no longer appears in the list.

aws ec2 describe-network-interfaces --filters "Name=requester-managed,Values=true"

Confirmed by docs.aws.amazon.com

Did this fix it?

Cause 2 of 3

An interface was left behind, detached, after its service was deleted

1Check

If a service detached an interface but did not delete it, you can delete the detached interface yourself.

aws ec2 describe-network-interfaces --network-interface-ids eni-0123456789abcdef0 --query "NetworkInterfaces[0].Status"

2Fix

Delete the detached interface. An interface must be detached before it can be deleted.

aws ec2 delete-network-interface --network-interface-id eni-0123456789abcdef0

3Verify

The command prints nothing on success; list the interfaces to confirm.

aws ec2 describe-network-interfaces --network-interface-ids eni-0123456789abcdef0

Confirmed by docs.aws.amazon.com

Did this fix it?

Cause 3 of 3

Instances and gateways still exist in the VPC

1Check

Before deleting a VPC, terminate EC2 instances and delete load balancers, NAT gateways, transit gateway attachments and interface endpoints. The console shows the blocking resources.

aws ec2 describe-network-interfaces --filters Name=vpc-id,Values=vpc-0123456789abcdef0 --query "NetworkInterfaces[*].[NetworkInterfaceId, Description]" --output table

2Fix

Remove each blocker, then delete the VPC in the console, which also removes its subnets, route tables and similar parts.

aws ec2 delete-vpc --vpc-id vpc-0123456789abcdef0

3Verify

The VPC is gone from the list.

aws ec2 describe-network-interfaces --filters Name=vpc-id,Values=vpc-0123456789abcdef0

Confirmed by docs.aws.amazon.com

Did this fix it?

How do I stop it coming back?

  • Tear down stacks in reverse order: services first, then network.
  • Manage VPC resources in CloudFormation or Terraform so a stack delete removes them in the right order.
  • Tag everything with the project name so leftover interfaces are easy to trace.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Servers

AWS will not detach or delete an internet gateway

Deleting an internet gateway fails while it is attached to a VPC

An internet gateway cannot be deleted while it is attached to a VPC, and it cannot be detached while the VPC still has resources with public IP addresses or Elastic IP addresses.

2 causes, each with a fix

Servers

Apache has a certificate, but https:// does not open

No line with :443 in the output of ss -ltnp

HTTPS needs four things at once: mod_ssl loaded, Apache listening on 443, a virtual host on 443 with SSLEngine on, and a firewall that lets 443 in.

4 causes, each with a fix

Servers

AWS CLI says you must specify a region

You must specify a region. You can also configure your region by running "aws configure".

The AWS CLI sends every request to one region and has none to use.

4 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.