AWS ECS Task Error: 'Unexpected EC2 error while attempting to Create Network Interface in subnet 'subnet-xxx': InsufficientFreeAddressesInSubnet'
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.
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:
- AWS Glue の「The specified subnet does not have enough free addresses to satisfy the request」エラーを解決する
- IP アドレスをサブネットに追加
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.