Error trying to detach network interface

0

Hello all,

I get the following error when trying to detach a network interface in CLI 2.0:

An error occurred (OperationNotPermitted) when calling the DetachNetworkInterface operation: The network interface at device index 0 cannot be detached.

Tried with both force and no force, instance is stopped still not able... Any help appreciated.

eni-attach-0867e4aaa19f25409 is this interface in question.

Thanks,

asked 3 years ago16381 views
2 Answers
0

Hi jflinnergex,

Sorry to hear about the inconvenience you are facing. The primary network interface is assigned to network card index 0, which is what you are trying to detach, however you can only detach a secondary network interface. Each instance has a default network interface, called the primary network interface. You cannot detach a primary network interface from an instance, and it will only get detached or released when the instance is terminated. If you need to preserve the ENI please make sure the delete on termination flag is not selected when terminating the instance: https://docs.aws.amazon.com/cli/latest/reference/ec2/modify-network-interface-attribute.html
For more information: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-eni.html#eni-basics

I hope this helps. Let me know if you have any questions.
Warm regards,
awsamy

amz99
answered 3 years ago
profile picture
EXPERT
reviewed 24 days ago
0

I also faced the same issue when I wanted to remove all the resources I had created. This act was to avoid any charges for the services I wasn't using. So if your case is also similar to this then terminate the EC2 instance. With the termination of the EC2 instance-associated Network interfaces, subnets will get removed. However please cross check once on the EC2 dashboard what services are being used post termination.

answered 9 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions