- Newest
- Most votes
- Most comments
When a task in an ECS service fails a load balancer health check, the service scheduler should replace it based on specific logic. However, there are several factors that could explain why your unhealthy tasks weren't automatically replaced.
The replacement process depends on the maximumPercent and desiredCount parameters in your service definition. When a task is marked unhealthy, the service scheduler first attempts to start a replacement task before stopping the unhealthy one. If the replacement task becomes healthy, the scheduler stops the unhealthy task. If the replacement task also becomes unhealthy, the scheduler will stop either the unhealthy replacement or the existing unhealthy task to maintain the desired count.
If your maximumPercent parameter is limiting the scheduler from starting replacement tasks first, the scheduler will stop unhealthy tasks one at a time at random to free up capacity before starting replacements. This process continues until all unhealthy tasks are replaced with healthy ones.
For your specific case where no action was taken despite unhealthy target groups, several issues could be at play:
- The ECS service might not be receiving the health status information from the load balancer
- There might be capacity constraints preventing new tasks from starting
- There could be IAM permission issues affecting the task execution
- If tasks are running manually (not as part of a service), they would continue regardless of health status
To troubleshoot further, you should check:
- Service configuration parameters (especially
maximumPercentanddesiredCount) - IAM roles and permissions
- Cluster capacity
- Network configuration
- Container health check settings
Sources
ECS ELB integration- How does Healthy Threshold Count work if unhealthy tasks are restarted? | AWS re:Post
Amazon ECS services - Amazon Elastic Container Service
Update Amazon ECS service parameters - Amazon Elastic Container Service
ECS deployment task failed (deployed on EC2) | AWS re:Post

ECS isn't even reporting the tasks as unhealthy, let alone refusing to start because of lack of capacity.
This:
The ECS service might not be receiving the health status information from the load balancer
appears to be the case, but this appears to be a cause internal to the implementation of AWS and not something that I can control.