Reputation: 946
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
Upvotes: 14
Views: 43463
Reputation: 13
after exploring a lot of stuff, the answer is quite simple, you just have to go to "EC2 =>Target groups => instance which causing issue => Edit health check settings" and then just have to add an api with slash e.g (/login) which return 200 response, or you can create a new api for it specifically
@app.route('/login')
def index():
return 'OK', 200
Upvotes: 0
Reputation: 461
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.
Upvotes: 46
Reputation: 1155
In DotNet I added this controller that will allow anonymous access and then in EC2 > Load Balancing > Target Group set the health check path to /health
public class HealthController : Controller
{
[AllowAnonymous]
public IActionResult Index()
{
return Ok($"HEALTH: OK - {DateTime.Now}");
}
}
Under Advanced Settings, include the HTTP code 302 to the expected results
Upvotes: 1
Reputation: 1976
For me, this was as simple as making sure the route that the health check is pointed to, like '/' for my example, returns a 200 result.
const router = require("express").Router();
// Health Check
router.get('/', (req, res)=>{
res.sendStatus(200);
})
module.exports = router;
Upvotes: 0
Reputation: 5687
This seem to have helped me, in
"health check settings" > "Advanced health check settings"
Under: "Port" from "Traffic port" to "Override" and used "80"
Under: "Success codes"
One Instance of EB from "200" to "200,300,301,302,303,304,305,306,307,308" (In Elastic Beanstalk Health was down because of "3xx Responses")
Second Instance of EB from "200" to "200,400,401,402,403,404,405,406,407,408,409,410,411,412,413,414,415,416,417,418,422,425,426,428,429,431,451" (In Elastic Beanstalk Health was down because of "4xx Responses")
Upvotes: 0
Reputation: 45094
I had a similar problem. In my case the fix was to change the health check's "Success codes" setting from 200
to 200,301
.
Upvotes: 12
Reputation: 12698
Typically your app is going to get deploy exposing it's native port. In the case of java this is usually 8080, with node it's 3000. Then AWS will, as part of EB, will still a proxy of either apache or nginx in front of your app exposing port 80. It's ELB that exposes port 443 to the outside.
So you probably want to change the port and protocol to 80 / HTTP
Upvotes: 0