Search code examples
amazon-web-servicesamazon-ec2amazon-ecsaws-application-load-balancer

Application load balancer failing health check to HTTP AWS ECS service with network mode bridge and dynamic port mapping


I'm trying to setup a HTTP server through an AWS ECS service with application load balancer, the ECS service uses the bridge network mode in an EC2 instance so that I can use dynamic port mapping.

The task was able to run, but it keeps failing the health check on the load balancer.

I checked inside the EC2 instance hosting the ECS service that I was able to curl successfully to the HTTP server with the dynamic port that was assigned.

I checked inside a different EC2 instance within the same VPC and ran curl to the HTTP server but got a Connection timed out error. I can confirm that other ECS services using the host network mode was accessible through curl.

I have made sure I've setup a security group for the EC2 instance to allow all traffic from within the VPC.

What could I be missing here?


Solution

  • You got a Connection timeout error, I think the firewall configuration is wrong. You need to check NACL and Security Group. If you want ALB can call healthcheck successfully,

    • All Security group of behind servers (EC2) need to allow ALL TCP ports from the Security Group id of ALB.
    • NACL Inbound and Outbound Rule Allow All traffic from anywhere