How do I resolve "the closest matching container-instance container-instance-id encountered error 'AGENT'" error for my service in Amazon ECS?
Last updated: 2019-07-03
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. The closest matching container-instance container-instance-id encountered error 'AGENT'."
You can receive this error when the Amazon ECS container agent running on the container instance designated for task placement is disconnected.
Note: If you didn't receive the preceding error message, choose an article based on one of the following error messages that you received:
To resolve this error, try the following troubleshooting steps:
Check your agent logs
2. Check your agent logs at /var/log/ecs/ecs-agent.log.YYYY-MM-DD-HH.
Note: Replace the timestamp with one that's appropriate for your logs.
Verify that the agent is running on the instance
2. To return a list of your containers, run the following command:
Look for a container running with the name ecs-agent. For more information, see Why is my Amazon ECS agent listed as disconnected?
Restart the agent
If you're using the Amazon ECS-optimized AMI, stop and restart the agent with the appropriate command.
For Amazon ECS-optimized Amazon Linux 2 AMIs, run the following command:
sudo systemctl restart ecs
For Amazon ECS-optimized Amazon Linux AMIs, run the following command:
sudo stop ecs && sudo start ecs