AWS ECS Task Error: 'Unexpected EC2 error while attempting to Create Network Interface in subnet 'subnet-xxx': InsufficientFreeAddressesInSubnet'

Tadashi Shigeoka ·  Thu, June 17, 2021

I’ll introduce the story of encountering and resolving the Unexpected EC2 error while attempting to Create Network Interface in subnet ‘subnet-xxx’: InsufficientFreeAddressesInSubnet error in AWS ECS Task.

AWS

Background: ECS Tasks Not Starting Due to Error

ECS tasks were not starting due to errors, and the following error was occurring frequently:

Unexpected EC2 error while attempting to Create Network Interface in subnet ‘subnet-xxx’: InsufficientFreeAddressesInSubnet

Solution: Stop Old ECS Tasks

Due to a bug in the application code, ECS tasks were not terminating and remained running, so I stopped the old ECS tasks as a temporary measure.

After that, I also fixed the application code bug as a fundamental solution.

While not directly related articles, the following AWS official support knowledge center articles were helpful:

That’s all from the Gemba about panicking when the AWS ECS Task “Unexpected EC2 error while attempting to Create Network Interface in subnet ‘subnet-xxx’: InsufficientFreeAddressesInSubnet” error occurred.