Search code examples
amazon-web-servicesaws-fargateaws-application-load-balancer

AWS ECS error: Task failed ELB health checks in Target group


I am using cloud formation template to build the infrastructure (ECS Fargate cluster). Template executed successfully and stack has been created successfully. However, task has failed with the following error:

Task failed ELB health checks in (target-group arn:aws:elasticloadbalancing:eu-central-1:890543041640:targetgroup/prc-service-devTargetGroup/97e3566c8b307abf)

I am not getting what and where to look for this to troubleshoot the issue. As it is Fargate cluster, I am not getting how to login to container and execute some health check queries to debug further.

Can someone please help me to guide further on this and help me? Due to this error, I am not even able to access my web app. As ALB won't route the traffic if it is unhealthy.

What I did

After some googling, I found this post: https://aws.amazon.com/premiumsupport/knowledge-center/troubleshoot-unhealthy-checks-ecs/

However, I guess, this is related to EC2 compatibility in Fargate. But in my case, EC2 is not there.


Solution

  • This is resolved. It was the issue with the following points:

    • Docker container port mapping with host port were incorrect
    • ALB health check interval time was very short. Due to that, ALB was giving up immediately, not waiting for docker container to up and running properly.

    after making these changes, it worked properly