Search code examples
amazon-web-servicesamazon-ec2amazon-ecs

Health check failed in dynamic port set-up in AWS ECS


My ECS set-up keeps on failing in health check when I set it up with dynamic port.

Here is my set-up:

I have a spring-boot web app which uses port 10440. So in my Task Definition I use port 0 as my Host Port to enable dynamic porting and 10440 as my container port. I have two 2 ec2 instances and run 2 task in my service. But my task are keep on terminating due to failing health check.

Screenshots:

-Task event logs

-Unhealthy regitered ec2 instances in target group

Note: If change my Host port to 10440 also, the set-up works fine. But I cannot run more task than the number of ec2 instance.

Screenshot: Health registered ec2 instance in target group

I hope someone can help so I can setup my ECS to run more task in 2 instances. Thank you!


Solution

  • I just figure out the problem. Upon executing

    aws elbv2 describe-target-health --target-group-arn

    I have found out that health check is having a timeout error, so I just prolong the timeout in health check setting.