One confusing situation when working with Amazon ECS is seeing your task in the RUNNING state while your application remains inaccessible.
The container is running, the ECS service looks healthy at first glance, but requests to your application fail or time out.
The problem is often related to networking or traffic routing rather than the container itself.
Here are five things worth checking.
1. Security Groups
Security groups control the traffic allowed into and out of your resources.
Check whether:
- The ECS task security group allows inbound traffic on the application port.
- The load balancer security group allows traffic from the intended clients.
- The ECS task security group allows traffic from the load balancer security group.
A missing inbound rule can prevent traffic from reaching an otherwise healthy application.
2. Container Port Configuration
Make sure the application is listening on the expected port.
For example, if your Node.js application listens on port 4000, verify that the ECS task definition and load balancer target group use the correct container port.
Also remember that an application listening on 127.0.0.1 may not accept traffic arriving through the container network interface. For a typical containerized API, it should listen on 0.0.0.0.
3. Subnets and Route Tables
Your subnet configuration determines how your ECS tasks communicate with other resources and the internet.
For public-facing services, investigate:
- Whether the task has an appropriate public or private network configuration.
- Whether the subnet route table has the required routes.
- Whether private subnets have NAT connectivity when outbound internet access is needed.
A running task doesn't automatically have internet connectivity.
4. Application Load Balancer Health Checks
If you're using an Application Load Balancer, check the target group's health status.
Common problems include:
- Incorrect health check paths.
- Wrong health check ports.
- Application startup taking longer than expected.
- Health check endpoints returning unexpected HTTP status codes.
An unhealthy target can prevent the load balancer from routing traffic to your application.
5. Verify the Application Itself
Finally, inspect your container logs in CloudWatch.
Look for:
- Application startup errors.
- Database connection failures.
- Missing environment variables.
- Incorrect listening ports.
Infrastructure can be configured correctly while the application itself is failing.
Final Thoughts
When an ECS task is running but your application is unreachable, don't immediately restart the service or increase its resources.
Follow the traffic path systematically:
Client → Load Balancer → Security Groups → ECS Task → Container Port → Application
Identifying where the connection breaks is usually much more effective than randomly changing configurations.
Loading article