Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fix 'Health checks failed with these codes: ' on elasticbeanstalk instace?

My application has Health Status of Severe because of Target.ResponseCodeMismatch error.

I've tried following Redirection is not configured on the backend in this aws instruction . And I've changed my port to '443' and my protocol to 'HTTPS' on eb config and redeployed. It changes the Health Status to Ok but when I access my url I get the page 'Index of' only

Here is what eb status --verbose returns:

Description: Health checks failed with these codes: [301]
Reason: Target.ResponseCodeMismatch

And this is from eb config:

AWSEBV2LoadBalancerListener.aws:elbv2:listener:default:
  DefaultProcess: default
  ListenerEnabled: 'true'
  Protocol: HTTP
  Rules: null
  SSLCertificateArns: null
  SSLPolicy: null
AWSEBV2LoadBalancerListener443.aws:elbv2:listener:443:
  DefaultProcess: default
  ListenerEnabled: 'true'
  Protocol: HTTPS
  Rules: null
  SSLCertificateArns: arn:aws:acm:us-east-2:XXXX:certificate/XXXXXX
  SSLPolicy: ELBSecurityPolicy-XX-XX-XXXX  
aws:elasticbeanstalk:environment:process:default:
  DeregistrationDelay: '20'
  HealthCheckInterval: '15'
  HealthCheckPath: /      
  HealthCheckTimeout: '5'
  HealthyThresholdCount: '3'
  MatcherHTTPCode: null
  Port: '443'
  Protocol: HTTPS
like image 934
sptramp Avatar asked Nov 27 '22 19:11

sptramp


1 Answers

For someone that may come across this as I did, I found the solution to be setting up the Health Check endpoint of the ELB target group to an actual URL on my website that returned an HTTP 200 code.

On the EC2 dashboard, under Load Balancing -> Target Groups, go to the tab Health Checks and edit the path to a path in your site that returns an 200 code.

View image - EC2 -> Load Balancing -> Target Groups

like image 169
filipe navas Avatar answered Dec 06 '22 02:12

filipe navas