Troubleshoot Health check failures for Amazon ECS tasks on AWS Fargate

AWS Fargate
AWS Fargate
The most common error you will receive during health check failures for Amazon ECS tasks on AWS Fargate. The errors are:
  • (service AWS-service) (port 8080) is unhealthy in (target-grouparn:uxyztargetgroup/aws-targetgroup/123456789) due to (reason Health checks failed with these codes: [502]) or [request timeout]
  • (service AWS-Service) (port 8080) is unhealthy in target-group tf-20190411170 due to (reason Health checks failed)
If you encounter any of the above errors, then follow these troubleshooting steps:
  1. If the container is mapped to port 80, then ensure that the container security group allows the load balancers inbound traffic on port 80.
  2. You must verify whether the load balancer health ping port value is properly configured or not. If the port is not properly configured, the load balancer could de-register the container itself.
  3. Verify the both ping port and health check path are properly configured.
  4. Define a minimum grace period for health checks. This informs the service scheduler to skip Elastic Load Balancing health checks once a task has been instantiated for a pre-defined amount of time.
  5. You should regularly monitor the CPU and memory statistics of the services.
  6. Monitor your application logs for any application errors.
  7. Check that your backend database is successfully connected.

Error 504 Troubleshooting

You will receive the error 504 due to any of the following reasons:
  • Load balancer fails to connect to the target before the connection expires.
  • Load balancer connected to the target, but it failed to respond before the idle timeout period expired.
  • Your subnet’s network access control list did not allow traffic from the targets to the load balancer nodes on the ephemeral ports.
(service AWS-Service) (port 8080) is unhealthy in target-group due to (reason Health checks failed with these codes:[504] If you receive the above 504 error, then try the following step:
  • Confirm that the backend has responded successfully without delay.
  • Set the correct response time-out value. The health check will fail if the value is lesser than the time required.
  • Also, Check your load balancer’s access logs for more information about issues.
Troubleshoot failed container health If you receive this error means your service is not integrated with the load balancer. But still the containers will use the health checks that your service cannot pass: (service AWS-Service) (task ff3e71a4-d7e5-428b-9232-2345657889) failed container health checks In case, if you have received the failed container health check error, follow the below steps:
  • First, confirm that you are passing the correct command to the container and syntax.
  • If the task has been running for some time, then check your application logs as well as the Amazon CloudWatch logs.
To get more updates you can follow us on Facebook, Twitter, LinkedIn

Subscribe to get free blog content to your Inbox
Loading

Written by actsupp-r0cks