AWS
Elastic Beanstalk
health state
4xx responses
application performance

Elastic Beanstalk disable health state change based on 4xx responses

System Design practice on Codemia

Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.

Practice system design

Introduction

Yes, Elastic Beanstalk enhanced health can be configured so that expected HTTP 4xx responses do not degrade the environment health state. This is useful when your application legitimately returns many client-side errors, such as 401, 403, or 404, and you do not want those responses to be treated as an infrastructure health problem.

Understand What Elastic Beanstalk Is Scoring

Enhanced health reporting looks at more than CPU and instance status. It also considers HTTP response patterns. By default, application 4xx responses contribute to environment health degradation, and load balancer 4xx responses can matter too.

That default is reasonable for many apps, but it becomes noisy for systems where:

  • clients frequently probe invalid URLs
  • authentication failures are common and expected
  • AWS WAF or another edge rule intentionally generates many 403 responses

In those cases, the environment may be healthy even though many requests end in a 4xx code.

Use Enhanced Health Rule Customization

The setting is part of the enhanced health ConfigDocument under the aws:elasticbeanstalk:healthreporting:system namespace.

A common configuration disables application 4xx health impact while keeping load balancer 4xx checks enabled:

yaml
1option_settings:
2  aws:elasticbeanstalk:healthreporting:system:
3    SystemType: enhanced
4    ConfigDocument:
5      Version: 1
6      Rules:
7        Environment:
8          Application:
9            ApplicationRequests4xx:
10              Enabled: false
11          ELB:
12            ELBRequests4xx:
13              Enabled: true

If you also need to ignore load balancer 4xx responses, change that section too:

yaml
1option_settings:
2  aws:elasticbeanstalk:healthreporting:system:
3    SystemType: enhanced
4    ConfigDocument:
5      Version: 1
6      Rules:
7        Environment:
8          Application:
9            ApplicationRequests4xx:
10              Enabled: false
11          ELB:
12            ELBRequests4xx:
13              Enabled: false

This is the core configuration change people are usually looking for.

Apply It in .ebextensions

A practical way to store the setting in the application source is an .ebextensions file.

yaml
1option_settings:
2  aws:elasticbeanstalk:healthreporting:system:
3    SystemType: enhanced
4    ConfigDocument:
5      Version: 1
6      Rules:
7        Environment:
8          Application:
9            ApplicationRequests4xx:
10              Enabled: false

Deploy the application after adding the file. Elastic Beanstalk will apply the updated health-reporting rules to the environment.

This is better than making one-off console changes because the behavior becomes versioned and reproducible.

Console and Operational Considerations

You can also configure the rule through the Elastic Beanstalk console, but the source-controlled config is usually safer for teams.

Before disabling 4xx-based health degradation, confirm that the 4xx traffic is genuinely expected. Otherwise you may hide real problems such as:

  • broken routing
  • an authentication outage
  • a bad application deployment that suddenly returns 404 for valid endpoints

The rule should be used when 4xx volume is normal by design, not when it is merely convenient to ignore a problem.

Do Not Use This as a Substitute for Better Health Checks

A cleaner architecture is often to combine the health rule adjustment with a dedicated health endpoint that returns 200 OK and checks the dependencies you actually care about.

For example, your load balancer or environment health URL should usually point at something like:

python
1from flask import Flask
2
3app = Flask(__name__)
4
5@app.get("/health")
6def health():
7    return {"status": "ok"}, 200

That keeps health evaluation focused on system readiness rather than on arbitrary user request outcomes.

Common Pitfalls

  • Disabling 4xx-based health degradation without understanding the traffic pattern can hide a genuine application problem.
  • Changing only application 4xx rules while the load balancer is the source of the noisy 4xx responses leaves the health state unchanged.
  • Editing the console manually without codifying the change in .ebextensions makes the setup easy to lose later.
  • Treating expected 401 or 403 responses as a health issue is a monitoring design mistake; those are often application-level outcomes, not infrastructure failures.
  • Using rule customization instead of defining a clean health endpoint can make health reporting less precise than it should be.

Summary

  • Elastic Beanstalk enhanced health can be configured to ignore expected 4xx responses.
  • The setting lives in the enhanced health ConfigDocument under the health reporting namespace.
  • You can disable application 4xx checks, load balancer 4xx checks, or both.
  • Store the configuration in .ebextensions so the behavior is versioned and repeatable.
  • Ignore 4xx-driven health changes only when those responses are expected by design, not when they indicate a broken app.

Related reading
Course
Beginner
27 lessons
10 hours
System Design Fundamentals

Build a strong foundation in designing scalable, reliable distributed systems.

View the course
Track what you have practised

A free account saves your progress, solutions and study plan across every problem on Codemia.

System Design practice on Codemia

Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.

Practice system design

All Rights Reserved.