AWS ALB · HTTP 502

AWS ALB 502: Target Reset or Invalid Response

Investigate ALB 502 responses caused by target resets, malformed HTTP, TLS negotiation, or connection reuse. Compare ALB access logs with target logs.

Origin / Application

Decode a CDN or gateway error

Paste a captured HTTP response or enter a status and headers. Only the status and response headers are sent; common credential headers are filtered first.

Supports raw headers, full HTTP responses, JSON with status/statusCode and headers, cURL -v/-i response output, and HAR exports. HAR selects a server error first. cURL commands are never executed; request headers, response bodies, and common credential headers are excluded.

Diagnostic report

Error code / name

AWS_ALB_502_TARGET_RESET

Fault domain

Origin / Application

Why it happened

The load balancer connected to a target, but the target reset the connection, returned invalid HTTP, or failed a target-side TLS handshake. Idle keep-alive mismatches can close a reused connection unexpectedly.

Actionable fixes

  1. Match the ALB access-log error reason with target application and TLS logs.
  2. Verify target protocol, port, response framing, and certificate settings when the target group uses HTTPS.
  3. Align application keep-alive behavior with the ALB idle timeout and drain connections gracefully during deploys.

Why this error happened

The load balancer connected to a target, but the target reset the connection, returned invalid HTTP, or failed a target-side TLS handshake. Idle keep-alive mismatches can close a reused connection unexpectedly.

Actionable fixes

  1. Match the ALB access-log error reason with target application and TLS logs.
  2. Verify target protocol, port, response framing, and certificate settings when the target group uses HTTPS.
  3. Align application keep-alive behavior with the ALB idle timeout and drain connections gracefully during deploys.

Network failure point

Client -> ALB -> target TCP connection -> reset or invalid response -> X 502

Verify origin directly via CLI

curl -sS -v -I --connect-timeout 5 --max-time 15 --resolve app.example.com:443:TARGET_IP https://app.example.com/health

Configuration fix

server.tstypescript
const server = app.listen(process.env.PORT ?? 3000);
server.keepAliveTimeout = 65_000;
server.headersTimeout = 66_000;

Catch this failure before it becomes an outage

SteadyNode's multi-region probes detect recurring 502 responses and preserve timing and response headers, helping distinguish a target reset from an ALB listener change.

No credit card required.

Start for free

Frequently asked questions

Can an ALB target return a malformed response that causes 502?

Yes. Invalid HTTP status lines, premature closes, and protocol mismatches can prevent the load balancer from parsing a valid target response.

Can keep-alive settings cause intermittent ALB 502 errors?

Yes. A target that closes a reused connection unexpectedly can cause intermittent resets; align keep-alive and idle-timeout behavior.

Cloudflare

Vercel and Netlify

AWS CloudFront and ALB

Fastly

Heroku and Render

Nginx and Envoy