Home / AWS

AWSTroubleshootingIntermediate

Elastic Beanstalk environment health Degraded or Severe: read the cause, find the failing instance and roll back

Turn an Elastic Beanstalk Red or Yellow health status into a cause with the CLI, read the right logs on Amazon Linux 2023 platforms, and roll back or recover the environment safely.

Deepak Bhardwaj6 min read

Applies toAWS Elastic Beanstalk with enhanced health reporting, Amazon Linux 2 and Amazon Linux 2023 platform branches, AWS CLI v2, EB CLI 3.x

The Beanstalk console shows the environment as Degraded or Severe (Red), or Warning (Yellow), often right after a deployment or config change. Users may be getting 5xx errors. The health status is an aggregate. The useful information is in the causes and in per-instance health, and both are available from the CLI.

Step 1: read the causes

Enhanced health reporting is on by default for current platform branches. Pull the environment and instance views:

ENV=orders-prod

aws elasticbeanstalk describe-environment-health \
  --environment-name "$ENV" --attribute-names All \
  --query '{Status:Status,Color:Color,Causes:Causes,Req:ApplicationMetrics.StatusCodes}'

aws elasticbeanstalk describe-instances-health \
  --environment-name "$ENV" --attribute-names All \
  --query 'InstanceHealthList[].{Id:InstanceId,Health:HealthStatus,Color:Color,Causes:Causes,Deploy:Deployment.VersionLabel}' \
  --output table

Then the recent error and warning events, which usually name the failing step:

aws elasticbeanstalk describe-events --environment-name "$ENV" \
  --severity WARN --max-items 30 \
  --query 'Events[].[EventDate,Severity,Message]' --output text

With the EB CLI, eb health --refresh shows the same data live.

Step 2: match the cause to a fix

The exact wording of cause messages varies by platform version. These are the common ones:

Cause (paraphrased) Likely reason Fix
"x % of the requests are failing with HTTP 5xx" App errors, crashed process behind nginx, bad config or secret Read web.stdout.log and nginx error.log; roll back the version
"Process default has been unhealthy" / ELB health check failing Health check path returns non-200, app listens on the wrong port, slow start Fix HealthCheckPath or the PORT the app binds to
"Command failed on instance" / "Instance deployment failed" Build, dependency install, .platform hook or .ebextensions command failed Read eb-engine.log and eb-hooks.log
"Incorrect application version found on N out of M instances" A deployment partly failed or instances replaced mid-deploy Redeploy the intended version, or roll back
"None of the instances are sending data" Health agent can't report, or instances aren't running Check instance state, instance profile, outbound network
High CPU or load average on all instances Under-sized instances or a runaway process Scale out, check the process, review Auto Scaling triggers
"Environment health has transitioned to Severe" during a rolling deploy Batch size too large, capacity reduced below demand Use rolling with additional batch or immutable deployments

Step 3: get the logs

Request the last 100 lines of the main logs from every instance, then download them:

aws elasticbeanstalk request-environment-info --environment-name "$ENV" --info-type tail
# wait 30-60 seconds
aws elasticbeanstalk retrieve-environment-info --environment-name "$ENV" --info-type tail \
  --query 'EnvironmentInfo[].[Ec2InstanceId,Message]' --output text

Each Message is a presigned S3 URL. Use --info-type bundle for full logs. With the EB CLI: eb logs or eb logs --all.

On Amazon Linux 2 and Amazon Linux 2023 platforms, read these first:

Log What it tells you
/var/log/eb-engine.log Every deployment step and the command that failed
/var/log/eb-hooks.log Output of your .platform/hooks scripts
/var/log/web.stdout.log Your application's stdout and stderr
/var/log/nginx/error.log Upstream connection refused or timed out (app not listening)
/var/log/cfn-init.log .ebextensions commands and container_commands

If you can reach an instance with Session Manager or eb ssh, search for the failing line directly:

sudo grep -nE "ERROR|failed|Command .* failed" /var/log/eb-engine.log | tail -20
sudo tail -50 /var/log/web.stdout.log
sudo grep -c "connect() failed" /var/log/nginx/error.log

connect() failed (111: Connection refused) while connecting to upstream in nginx means the app is not listening on the port nginx proxies to. On most platforms that is port 5000 or the value of the PORT environment property.

Step 4: fix or roll back

Roll back to the last good version

This is usually the fastest fix after a bad deploy. Find the previous version label and deploy it:

aws elasticbeanstalk describe-application-versions --application-name orders \
  --max-records 5 --query 'ApplicationVersions[].[VersionLabel,DateCreated,Status]' --output table

aws elasticbeanstalk update-environment --environment-name "$ENV" --version-label v2026-11-24-1

If a deployment is still in progress and making things worse, stop it first:

aws elasticbeanstalk abort-environment-update --environment-name "$ENV"

Warning

Aborting a rolling deployment leaves instances on mixed versions. Follow it with an explicit update-environment to the version you want, then check describe-instances-health until every instance reports the same label.

Fix the health check

For an environment with an Application Load Balancer, the health check path belongs to the process:

aws elasticbeanstalk update-environment --environment-name "$ENV" --option-settings \
  Namespace=aws:elasticbeanstalk:environment:process:default,OptionName=HealthCheckPath,Value=/healthz \
  Namespace=aws:elasticbeanstalk:environment:process:default,OptionName=MatcherHTTPCode,Value=200

Make /healthz cheap and independent of downstream dependencies, or one slow database will mark every instance unhealthy at once.

Restart the app without replacing instances

aws elasticbeanstalk restart-app-server --environment-name "$ENV"

This restarts the application server on every instance. It helps with a leaked-memory or wedged process, not with a broken deployment.

Caution

rebuild-environment terminates and recreates all resources in the environment, including an RDS instance created by Beanstalk inside the environment. Data in that database is lost unless you have a snapshot. Prefer rollback, restart-app-server or replacing single instances first.

Instances not reporting

If causes say no instances are sending data:

aws elasticbeanstalk describe-environment-resources --environment-name "$ENV" \
  --query 'EnvironmentResources.{ASG:AutoScalingGroups[].Name,Instances:Instances[].Id}'

aws autoscaling describe-scaling-activities \
  --auto-scaling-group-name <asg-name> --max-items 5 \
  --query 'Activities[].[StatusCode,StatusMessage]' --output text

Look for launch failures (quota, capacity, missing instance profile) and check that instances in private subnets have a route to the Beanstalk and CloudWatch endpoints through a NAT gateway or VPC endpoints.

Prevent it next time

  • Safer deployment policy. Use Immutable or RollingWithAdditionalBatch in production so capacity never drops during a deploy:

    aws elasticbeanstalk update-environment --environment-name "$ENV" --option-settings \
      Namespace=aws:elasticbeanstalk:command,OptionName=DeploymentPolicy,Value=Immutable
    
  • Alarm on health, not just on the console colour. Publish the EnvironmentHealth custom metric through the enhanced health config, then alarm on it in CloudWatch. Metric availability depends on your health reporting configuration; check it in the environment's monitoring settings.

  • Stream logs to CloudWatch Logs (aws:elasticbeanstalk:cloudwatch:logs, StreamLogs=true) so you can read logs from instances that have already been replaced.

  • Keep previous versions. Set the application version lifecycle to retain enough versions for a rollback, and tag the last known-good label in your pipeline.

  • Stay on a supported platform branch. Retired branches stop getting fixes. Check the platform branch status in the Beanstalk console or with aws elasticbeanstalk describe-platform-version and plan upgrades with a blue/green environment and swap-environment-cnames.