---
title: "CodeDeploy health constraints: failed instances or an impossible setting? | Proofline"
description: "A HEALTH_CONSTRAINTS failure means instances failed during the rollout."
url: https://proofline.sh/learn/codedeploy-health-constraints/
---

[Learning center](/learn/)

# CodeDeploy health constraints: failed instances or an impossible setting?

A HEALTH\_CONSTRAINTS failure means instances failed during the rollout. A HEALTH\_CONSTRAINTS\_INVALID failure means the minimum healthy hosts setting could never be met. Compare the deployment configuration's minimum, rounded up, with the number of instances in the deployment: that one calculation tells you whether to fix instances or the configuration.

Capacity overruns The Proofline team November 22, 2026 6 min read

## Two codes, two different failures

Both codes appear in a deployment's `errorInformation.code` on the EC2/on-premises compute platform. The API reference describes them in one line each, and the user guide's error-code table adds the remedy. [ErrorInformation](https://docs.aws.amazon.com/codedeploy/latest/APIReference/API_ErrorInformation.html) · [Error codes](https://docs.aws.amazon.com/codedeploy/latest/userguide/error-codes.html)

| Code | API reference | User guide |
| --- | --- | --- |
| `HEALTH_CONSTRAINTS` | The deployment failed on too many instances to be successfully deployed within the instance health constraints specified. | `The overall deployment failed because too many individual instances failed deployment, too few healthy instances are available for deployment, or some instances in your deployment group are experiencing problems.` |
| `HEALTH_CONSTRAINTS_INVALID` | The revision cannot be successfully deployed within the instance health constraints specified. | The deployment can't start because the minimum number of healthy instances is not available; reduce the required number or add instances to the deployment group. |

The first is a symptom with causes on the instances: failing hook scripts, an agent that is not running, stopped instances. The second is arithmetic. No instance failure is needed, and redeploying the same revision to the same group will fail the same way.

## Read the configuration and the instance count together

Use a read-only profile and replace the uppercase placeholders. The deployment names its configuration and summarizes its instances. [DeploymentInfo](https://docs.aws.amazon.com/codedeploy/latest/APIReference/API_DeploymentInfo.html) · [DeploymentOverview](https://docs.aws.amazon.com/codedeploy/latest/APIReference/API_DeploymentOverview.html)

```
aws deploy get-deployment \
  --profile PROFILE --region REGION --deployment-id DEPLOYMENT_ID \
  --query 'deploymentInfo.{status:status,error:errorInformation,config:deploymentConfigName,style:deploymentStyle,overview:deploymentOverview,created:createTime,completed:completeTime}' \
  --output json --no-cli-pager

aws deploy get-deployment-config \
  --profile PROFILE --region REGION --deployment-config-name DEPLOYMENT_CONFIG \
  --query 'deploymentConfigInfo.{name:deploymentConfigName,platform:computePlatform,minimumHealthy:minimumHealthyHosts,zonal:zonalConfig}' \
  --output json --no-cli-pager
```

`minimumHealthyHosts.type` is `HOST_COUNT`, an absolute number, or `FLEET_PERCENT`, a percentage of the instances in the deployment. For the predefined `CodeDeployDefault.OneAtATime`, `get-deployment-config` returns the type `MOST_CONCURRENCY` with a value of 1, which you cannot set yourself. A configuration with a `zonalConfig` can also set `minimumHealthyHostsPerZone`, the number or percentage of instances that must remain available in each Availability Zone, alongside the overall minimum; it defaults to 0 percent. [MinimumHealthyHosts](https://docs.aws.amazon.com/codedeploy/latest/APIReference/API_MinimumHealthyHosts.html) · [ZonalConfig](https://docs.aws.amazon.com/codedeploy/latest/APIReference/API_ZonalConfig.html)

Add the counts in `deploymentOverview` (`Pending`, `InProgress`, `Succeeded`, `Failed`, `Skipped`, `Ready`) to get the number of instances the deployment covered. That count is the denominator for the next section.

## A worked calculation

CodeDeploy applies four rules, all from its instance health documentation. [CodeDeploy instance health](https://docs.aws.amazon.com/codedeploy/latest/userguide/instances-health.html#minimum-healthy-hosts)

1.  At the start, a percentage is converted to a number of instances, **rounding up**.
2.  If the number of healthy instances is already less than or equal to the minimum when the deployment starts, CodeDeploy fails the overall deployment immediately. That is the condition the error-code table describes for `HEALTH_CONSTRAINTS_INVALID`.
3.  Otherwise CodeDeploy deploys to as many instances at a time as it can without the healthy count falling below the minimum, and stops the deployment when the healthy count falls to the minimum.
4.  At least one instance must succeed, even with a minimum of 0. With `OneAtATime`, a failure on the last instance still leaves the deployment successful.

For a deployment group of 10 instances:

| Minimum healthy hosts | Converted minimum | Instances at a time | What fails it |
| --- | --- | --- | --- |
| `FLEET_PERCENT` 95 | 10 (9.5 rounded up) | None | It fails before deploying anywhere: 10 healthy is not more than 10 |
| `FLEET_PERCENT` 85 | 9 (8.5 rounded up) | 1 | The first failed instance |
| `HOST_COUNT` 9 | 9 | 1 | Any failure, except on the last instance |
| `HOST_COUNT` 8 | 8 | 2 | Two failures |
| `HOST_COUNT` 0 | 0 | 10 | All 10 failing |

The API reference gives a nine-instance example with the same rules: a `HOST_COUNT` of 6 deploys to three instances at a time, and a `FLEET_PERCENT` of 40 (3.6, rounded up to 4) deploys to five at a time. `CodeDeployDefault.HalfAtATime` deploys to up to four of nine at a time and needs five to succeed. [Predefined configurations](https://docs.aws.amazon.com/codedeploy/latest/userguide/deployment-configurations.html#deployment-configurations-predefined)

The rounding is what makes a configuration that looks reasonable impossible. 90 percent of 10 instances leaves room for one instance at a time. 90 percent of 6 instances is 5.4, which rounds up to 6, so a six-instance group can never run that configuration.

## What changes the count

The denominator is the deployment group's instances as CodeDeploy sees them, which is not always the number you expect.

-   **Stopped instances count as failed.** CodeDeploy attempts to deploy to instances in the Stopped state, and in the minimum healthy host calculation a stopped instance has the same impact as a failed one. Restart them or change their tags to take them out of the group. [Instance health](https://docs.aws.amazon.com/codedeploy/latest/userguide/instances-health.html#minimum-healthy-hosts)
-   **Newly tagged instances may be missing.** CodeDeploy can take several minutes to read new tags, and AWS recommends waiting at least five minutes after tagging before deploying. [Tags](https://docs.aws.amazon.com/codedeploy/latest/userguide/troubleshooting-ec2-instances.html#troubleshooting-EC2-tags)
-   **Blue/green counts the replacement environment.** The minimum applies to the replacement instances, not the original ones. Separately, the deployment fails if even one original instance fails to deregister from the load balancer. [Instance health](https://docs.aws.amazon.com/codedeploy/latest/userguide/instances-health.html)

## An illustrative pair of failures

These records are fictional. The deployment group `orders-prod` runs on six instances.

The first deployment uses a custom configuration, `orders-90pct`, with `FLEET_PERCENT` 90. It ends in seconds with `HEALTH_CONSTRAINTS_INVALID`, and `deploymentOverview` shows no instance in `Succeeded` or `Failed`. The calculation is 5.4 rounded up to 6, which equals the number of healthy instances, so CodeDeploy could never take one offline. Nothing on the instances needs fixing. Lower the minimum to 5 hosts or fewer, or add instances.

The second deployment uses `HOST_COUNT` 5 on the same six instances. CodeDeploy deploys to one instance at a time. The first instance fails, leaving five healthy instances, which equals the minimum, so the deployment stops with `HEALTH_CONSTRAINTS`. The deployment target shows `AfterInstall` failed with `ScriptFailed`. The configuration did its job: it stopped a revision that failed on its first instance. The next read is that instance's diagnostics, covered in [the ScriptFailed guide](/learn/codedeploy-scriptfailed-lifecycle-event/).

## What to change

For `HEALTH_CONSTRAINTS_INVALID`, change the arithmetic: a lower minimum, a `HOST_COUNT` instead of a percentage, or more instances. Check the result against the rounding rule before you deploy again.

For `HEALTH_CONSTRAINTS`, change the instances or the revision. Lowering the minimum lets more instances fail before CodeDeploy stops, which spreads a broken revision further. Read the failed targets first:

```
aws deploy list-deployment-targets \
  --profile PROFILE --region REGION --deployment-id DEPLOYMENT_ID \
  --target-filters '{"TargetStatus":["Failed","Skipped"]}' \
  --query 'targetIds' --output json --no-cli-pager
```

A failed lifecycle event with a script error points at the revision or the instance. If every lifecycle event was skipped, AWS lists the agent not running, no route to the CodeDeploy or S3 endpoint on port 443, missing service role permissions, clock skew and a missing instance profile among the causes; see [why CodeDeploy events stay pending](/learn/codedeploy-agent-timeout/). [Skipped lifecycle events](https://docs.aws.amazon.com/codedeploy/latest/userguide/troubleshooting-deployments.html#troubleshooting-skipped-lifecycle-events)

## Where the calculation stops

The rules above are CodeDeploy's own description of in-place EC2/on-premises deployments. They do not cover ECS or Lambda deployments, which shift traffic instead of taking hosts offline. An instance's health in CodeDeploy means only that the last deployment to it succeeded; it says nothing about load balancer health or whether the application serves requests. For the matching fields in other AWS deployment services, see the [signature table](/learn/aws-deployment-failure-signatures/).

## Questions

### Why did my CodeDeploy deployment fail without deploying to any instance?

If the minimum healthy hosts value, rounded up, is greater than or equal to the number of healthy instances at the start, CodeDeploy fails the deployment immediately, which the error-code table reports as `HEALTH_CONSTRAINTS_INVALID`. Lower the minimum or add instances.

### Does a minimum healthy hosts value of 0 mean a deployment always succeeds?

No. CodeDeploy deploys to every instance at once, and at least one instance must succeed for the overall deployment to succeed.

### Why does one failed instance fail my whole deployment?

With a high minimum, such as 85 percent of 10 instances, the converted minimum is 9, so CodeDeploy deploys one instance at a time and stops when the healthy count reaches 9. One failure is enough to reach it.

## One month of free code review.

New organizations get one calendar month of hosted code review for private and public GitHub repositories. No card or cloud connection required. [Eligibility and fair-use terms](/free-code-review/).

[Start free with GitHub](https://proofline.sh/orgs/plan?offer=free_month)

## Related reading

-   ### [CodeDeploy ScriptFailed: which hook, which script, which revision](/learn/codedeploy-scriptfailed-lifecycle-event/)
    
    Deployment failures The Proofline team November 22, 2026 6 min read
    
-   ### [CodeDeploy events stuck in Pending: agent, endpoint or slow script](/learn/codedeploy-agent-timeout/)
    
    Deployment failures The Proofline team November 22, 2026 7 min read
