Interview Prep/AWS/EC2, Auto Scaling and Load Balancing

ALB returns `503 Service Temporarily Unavailable` immediately.

BeginnerTroubleshootingEC2, Auto Scaling and Load Balancing
Answer

Likely causes → The target group behind the matched listener rule has no registered targets, or all of its targets are in AZs the ALB is not enabled in. If every target is unhealthy, the ALB "fails open" and still routes traffic, so 503 usually means no targets.

Diagnose →

aws elbv2 describe-rules --listener-arn <listener-arn> \
  --query 'Rules[].[Priority,Actions[0].TargetGroupArn]'
aws elbv2 describe-target-health --target-group-arn <tg-arn>
aws elbv2 describe-load-balancers --load-balancer-arns <alb-arn> --query 'LoadBalancers[].AvailabilityZones'

Fix →

  1. Register targets, or attach the ASG or ECS service to the right target group
  2. Enable the ALB in the AZs where the targets run

Prevent → Alarm on HealthyHostCount < 1 per target group, and check that targets are attached in your IaC.

aws All AWS questions Roadmap: AWS core services

More on EC2, Auto Scaling and Load Balancing