Aws Load balancer errors
Gather information to understand the problem
The first step is to try to understand the problem. To do this we need go gather the necessary information from the aws console and of the error responses from the load balancer and the instances.
1. Check the target groups’ instance health status
The status and the message from the targets is in the aws console. This is where you can find the information:
If the registered targets’ status is unhealthy, unused or draining then there is a problem with the registered targets. If this is the problem follow this:
- For more information check the Health check reason codes, that can give you a clue of the problem and of the solution. Look in here the explanation and possible solution for each Health check reason codes.
- Check for the following issues:
- A security group does not allow traffic. If this is the problem try this solution.
- A network access control list (ACL) does not allow traffic. If this is the problem try this solution.
- The ping path does not exist. If this is the problem try this solution.
- The connection times out or The target did not return a successful response code. If this is the problem try this:
Check that the UserData is correct and the ImageId (just for Cloudformation or directly using EC2, not for EKS)
- Check that the launch configuration’s UserData works correctly
- Check that you use the correct ImageId
It is important that you add a debugging statement to the UserData to get the error logs. Configure your UserData in your CloudFormation script so that you can see the logs of the invocation of the UserData in the System Log.
To troubleshoot issues on your EC2 instance bootstrap without having to access the instance through SSH, you can add code to your user-data bash script that redirects all the output both to the /var/log/user-data.log and to /dev/console. When the code is executed, you can see your user-data invocation logs in your console.
This tutorial will teach you how to do this.
Now it is important that you test the UserData and make sure that it works. This tutorial shows you how to create and test a UserData using an EC2 instance.
Check that the container image works well (aws eks only)
- Test in docker locally in your machine that you can run your docker image and that it works as expected. If it is a website you should be able to access it.
- Test in minikube locally in your machine that you can run your docker image and that it works as expected. To learn how to do this follow this tutorial.