user1779418
user1779418

Reputation: 495

AWS Load balancer health check: Health checks failed with these codes: [301]

I'm trying to set up an Elastic Beanstalk environment with an application load balancer and a dockerized app. When creating the EB environment, I set it in a VPC - the load balancer went into a public subnet and the EC2 instance went into a private subnet. There's a NAT gateway that the LB's subnet is attached to. The load balancer was created as an application load balancer, with a listener for ports 80 and 443 (using a self-signed certificate uploaded into ACM).

I launched the EB environment with a default sample app that AWS provides. When I do this, my load balancer target check is healthy. However, when I deploy my actual app into the EB environment, the load balancer target check starts to fail with the error code 301. I'm at a loss of what to do or how to figure out what's going wrong. If I redeploy the sample application the target check still remains as a failure.

Edit:

I tried accessing my app via the EB url, and Chrome errored out with a too many redirects error. Is this related?

Upvotes: 5

Views: 18109

Answers (2)

As posted in this link you can configure the target group to accept 301 status code also.

In the EC2 console select the target group -> Health checks -> Edit -> Advanced health check settings. In the 'Success codes' field add 301 also so that it reads 200, 301

Upvotes: 3

mahendra rathod
mahendra rathod

Reputation: 1638

Redirection configured on the backend can result in a 301 or 302 response code, resulting in failed health checks. For example, if you have a Redirection configured on the backend can result in a 301 or 302 response code, resulting in failed health checks. For example, if you have a redirection from HTTP:80 to HTTPS:443 on the backend, then HTTP health checks on port 80 will fail, unless you change the health check to HTTPS and health check port to 443.

Upvotes: 4

Related Questions