amazon load balancer returns error code 400
Asked Answered
W

6

10

We have a load balancer on amazon which balance 4 servers. When sending specific HTTP request to the load balancer I get Http error code 400. But when I sends the same request to each one of the servers directly I get Http 200 OK. Other requests are working fine when using the balancer.

Any Ideas?

Thanks.

Whipstall answered 9/1, 2013 at 18:27 Comment(2)
Welcome to Stackoverflow. In order to get good responses to questions please consider posting some sample codeEolith
Can you paste here the HTTP headers?Consequence
S
10

Don't know if this will help you, but I've had a similar problem. I was using jMeter and when accessing my instance over AWS load balancer I would always get: HTTP/1.1 400 BAD_REQUEST. After lot of debugging I found out that I was sending an empty header (no name and no value) because I had an empty row in HTTP Header Manager in jMeter. So, I persume, AWS ELB does some headers checking, and returns HTTP 400, even tough I wasn't having any problems with going with the same request to my instances directly. I don't know if this will help you but you should double-check your headers for some stupid mistake like this one :D

Sunburst answered 5/2, 2013 at 9:34 Comment(1)
O....M.....G! I can't believe that's what was holding me up and making me crazy. Thank you Mod, I don't think I would have noticed this discrepancy without you.Moorwort
C
5

I had a similar problem to this, and it was caused by ALB not accepting HTTP methods that are in lower case.

GET http://myhost.com/foo -> HTTP 200
get http://myhost.com/foo -> HTTP 400
Childs answered 4/6, 2018 at 17:8 Comment(1)
That was the case for us. Spec indeed says "all upper-case by convention" https://mcmap.net/q/657629/-http-method-names-upper-or-lower-caseFiddling
C
2

In my case it was the headers issue.

ELB-HealthChecker was sending healthcheck request to my web server and nginx replied with 400.

The issue was that ELB-HealthChecker sends no headers with the request. Depending on the configuration of your webserver, this might return 400 error code.

To check if this is the case, replicate "no headers" request with curl:

curl -I -H 'User-Agent:'  -H 'Accept:' -H 'Host:' http://yourservice/health/

The solution is to configure nginx endpoint that will return 200 regardless of the presence of the request headers:

location = /health/ { return 200; }
Chaoan answered 20/5, 2019 at 15:45 Comment(0)
S
1

In my case my target group for Port 443 was using HTTP protocol instead of HTTPs and I was getting 'Client using HTTP to connect to HTTPS server'

Sholeen answered 4/3, 2021 at 6:10 Comment(0)
T
0

I also had this issue when using the GET method on an ALB. It turns out that my client was adding the header Content-Length: 0 to the request. This caused the ALB to reject the request with a 400 error.

Talmud answered 7/6, 2023 at 13:1 Comment(0)
N
0

While you are facing this error please check the following points

1: Please change your target group health check protocol from HTTP to HTTPS which was in my case<br>
2: Health check path<br>
3: Success code

Before changes

enter image description here

enter image description here

After changes
enter image description here enter image description here

Narbonne answered 2/10, 2023 at 9:10 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.