How do I resolve the "[AWS service] was unable to place a task because no container instance met all of its requirements" error in Amazon ECS?
Last updated: 2022-03-01
When I try to place a task in Amazon Elastic Container Service (Amazon ECS), I receive the following error: "[AWS service] was unable to place a task because no container instance met all of its requirements."
Short description
You can receive this error due to one or more of the following reasons:
- No container instances were found in your cluster
- The port needed by the task is already in use
- Not enough memory for your tasks
- Not enough CPU units for your container instance
- Not enough available elastic network interface attachment points
- A required attribute is missing for your container instance
For more information on these issues, see Service event messages.
Note: If you didn't receive the preceding error message, choose an article based on one of the following error messages that you received:
- [AWS service] was unable to place a task because no container instance met all of its requirements. The closest matching container-instance container-instance-id has insufficient CPU units available.
- [AWS service] was unable to place a task because no container instance met all of its requirements. The closest matching container-instance container-instance-id encountered error "AGENT".
Resolution
To resolve the error, choose a resolution based on your use case:
- If there are no container instances registered in your cluster, then add container instances to your cluster.
- If the port required by the task is in use, then add container instances to your cluster, or reduce your number of desired tasks.
Note: If possible, consider using dynamic port mapping to allow your tasks to use any available port on a container instance. - If the container instance doesn't have enough memory for your tasks, then reduce the amount of memory in your task definition, or launch more container instances in your cluster.
Note: For more information, see the Not enough memory section in Service event messages under service (service-name) was unable to place a task because no container instance met all of its requirements. - If the container instance doesn't have enough CPU units, then adjust the CPU required by the tasks, or launch more container instances in your cluster.
Note: For more information, see the Not enough CPU section in Service event messages under service (service-name) was unable to place a task because no container instance met all of its requirements. Or, refer to How do I resolve "the closest matching container-instance container-instance-id has insufficient CPU units available" error in Amazon ECS? - If the container instance doesn't have any available elastic network interface attachment points, then add more container instances to your cluster.
Note: For more information, see the Not enough available ENI attachment points section in Service event messages under service (service-name) was unable to place a task because no container instance met all of its requirements. If the issue persists, consider using awsvpcTrunking to increase elastic network interface density on your Amazon Elastic Compute Cloud (Amazon EC2) instances. - If the container instance is missing a required attribute, then refer to the Container instance missing required attribute section in Service event messages under service (service-name) was unable to place a task because no container instance met all of its requirements. To find the missing attributes, run the ecs-cli check-attributes command.
Note: If you receive errors when running AWS CLI commands, make sure that you’re using the most recent version of the AWS CLI.
If you configured the Amazon ECS service to run on a subnet that's different from the subnet for the container instance, then the output of the ecs-cli-check-attributes command shows None for missing attributes even though the task fails with the missing attribute error. To make sure that the subnets for your service and the container instance are same, recreate the Amazon ECS service in the subnet where the container instance exists.
Note: For more information, see Task definition parameters and Amazon ECS container agent configuration.
Container Instance Missing Attributes
example-instance None
Related information
Did this article help?
Do you need billing or technical support?