# service unable to place tasks: reason: capacity is unavailable at this time.

- **ID:** `aws/ecs-task-stuck-pending-capacity`
- **Domain:** aws
- **Category:** resource_error
- **Verification:** ai_generated
- **Fix Rate:** 85%

## Root Cause

ECS cluster lacks sufficient EC2 or Fargate capacity to launch the task, often due to instance type unavailability in the AZ.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| ecs-2024-06 | active | — | — |
| fargate-1.4.0 | active | — | — |
| ecs-cli-2.0.0 | active | — | — |

## Workarounds

1. **Change the task placement strategy to spread across multiple AZs: `aws ecs update-service --cluster my-cluster --service my-service --placement-strategy type=spread,field=attribute:ecs.availability-zone`** (85% success)
   ```
   Change the task placement strategy to spread across multiple AZs: `aws ecs update-service --cluster my-cluster --service my-service --placement-strategy type=spread,field=attribute:ecs.availability-zone`
   ```
2. **Use a different instance type or Fargate platform version: update the task definition to use `FARGATE` or a different CPU/memory combination.** (75% success)
   ```
   Use a different instance type or Fargate platform version: update the task definition to use `FARGATE` or a different CPU/memory combination.
   ```

## Dead Ends

- **** — Restarting the ECS service doesn't free capacity; the underlying resource shortage persists. (90% fail)
- **** — Increasing task count makes the problem worse by requesting more unavailable capacity. (80% fail)
