Search code examples
amazon-web-servicesspring-bootamazon-ecsamazon-elbnlb

AWS Network load balancer health check is failing for ECS service


I have created a ECS service to deploy a spring-boot application. I have added the target group to Network load balancer by specifying the load balancer name while creating container for this service in aws ecs console.

Now When I check the health status of that target group it is continuously doing registration and deregistration with different IP addresses. I checked the security group also, it has allowed all ports and IPs.

Can anybody help here what could be the issue of not coming "healthy" status of the target group.

Please find attached screenshot of ECS service, health check status and security group used.

ECS service

Screenshot of health status of NLB

Screenshot of security group used while creating container

Target group health check settings

Screenshot of target group attached to ECS

creation of task definition

screenshot once task definition created

ECS service logs

Cluster dashboard screenshot

Screenshot of linking target group while creating service

Task definition screenshot 1


Solution

  • As discussed over comments, here is the issue with your setup.

    1. You are bringing the spring boot container on 8080 port so ECS Task Definition Container Port should be 8080(not 10001).
    2. Your Container Port & Target Group port should be in sync irrespective of Host Port or NLB Listener Port. So re-create the Target Group with Port as 8080 and re-create the ECS service attached to updated Target Group.
    3. Finally, it looks like your traffic is more of HTTP/HTTPS based so I would be probably suggest to use ALB(Application Load Balancer) instead of NLB. NLB works for all the TCP ports but you will get more advantages of using ALB for HTTP/HTTPS based traffic. I am not sure of your application fully so its a mere suggestion!!.