AWS

InsufficientCapacityException - Insufficient Capacity

Getting an **InsufficientCapacityException** means AWS doesn't have enough physical capacity in the requested Availability Zone to launch your EC2 instance—the specific instance type or zone is temporarily out of capacity. This client-side error (4xx) happens when AWS can't allocate hardware resources. Most common when launching EC2 instances in popular zones, but also appears when specific instance types are unavailable, regions have capacity constraints, Spot instances have no capacity, or temporary capacity issues occur.

#Common Causes

  • Identity: IAM permissions allow launch but capacity unavailable. Service Control Policy (SCP) restricts zones but capacity issue.
  • Network: VPC subnet in zone with no capacity. Security Group in unavailable zone.
  • Limits: No capacity in requested Availability Zone. Instance type not available in zone. Region capacity exhausted. Spot instance capacity unavailable. Temporary capacity issue (retry later).

Solutions

  1. 1Step 1: Diagnose - Check which zone/instance type failed: Review error message for specific Availability Zone. Note the instance type that failed. Check if it's Spot or On-Demand.
  2. 2Step 2: Diagnose - List available Availability Zones: aws ec2 describe-availability-zones --region REGION --query 'AvailabilityZones[*].[ZoneName,State]' --output table. Check zone state (available/unavailable).
  3. 3Step 3: Diagnose - Check instance type availability: aws ec2 describe-instance-type-offerings --location-type availability-zone --filters Name=instance-type,Values=INSTANCE_TYPE --query 'InstanceTypeOfferings[*].Location' --output table. Find zones with capacity.
  4. 4Step 4: Fix - Try different Availability Zone: aws ec2 run-instances --image-id ami-xxxxx --instance-type t2.micro --placement AvailabilityZone=us-east-1b. Loop through zones until one works.
  5. 5Step 5: Fix - Try different instance type: aws ec2 run-instances --image-id ami-xxxxx --instance-type t3.micro --placement AvailabilityZone=us-east-1a. Use similar instance families (t2 → t3, m5 → m5a). Retry after delay if temporary.

</>Code Examples

List Available Zones and Instance Types
1#!/bin/bash
2REGION="us-east-1"
3
4# List all Availability Zones
5echo "=== Availability Zones in ${REGION} ==="
6aws ec2 describe-availability-zones \
7  --region ${REGION} \
8  --query 'AvailabilityZones[*].[ZoneName,State]' \
9  --output table
10
11# Check instance type availability in zones
12INSTANCE_TYPE="t2.micro"
13echo "\n=== Checking ${INSTANCE_TYPE} Availability ==="
14aws ec2 describe-instance-type-offerings \
15  --location-type availability-zone \
16  --filters Name=instance-type,Values=${INSTANCE_TYPE} \
17  --region ${REGION} \
18  --query 'InstanceTypeOfferings[*].Location' \
19  --output table
Launch Instance with Zone Fallback
1#!/bin/bash
2AMI_ID="ami-xxxxx"  # Replace with valid AMI
3INSTANCE_TYPE="t2.micro"
4REGION="us-east-1"
5
6# Get available zones
7ZONES=($(aws ec2 describe-availability-zones \
8  --region ${REGION} \
9  --query 'AvailabilityZones[*].ZoneName' \
10  --output text))
11
12echo "=== Trying Zones: ${ZONES[*]} ==="
13
14# Try each zone until one works
15for ZONE in "${ZONES[@]}"; do
16  echo "\nTrying zone: ${ZONE}"
17  aws ec2 run-instances \
18    --image-id ${AMI_ID} \
19    --instance-type ${INSTANCE_TYPE} \
20    --placement AvailabilityZone=${ZONE} \
21    --count 1 \
22    --region ${REGION} 2>&1
23  
24  if [ $? -eq 0 ]; then
25    echo "✓ Successfully launched in ${ZONE}"
26    break
27  else
28    echo "✗ No capacity in ${ZONE}, trying next..."
29  fi
30done
Try Different Instance Types as Fallback
1#!/bin/bash
2AMI_ID="ami-xxxxx"
3ZONE="us-east-1a"
4
5# Fallback instance types (similar families)
6FALLBACK_TYPES=("t3.micro" "t2.micro" "t3.small" "t2.small")
7
8echo "=== Trying Instance Types in ${ZONE} ==="
9for INSTANCE_TYPE in "${FALLBACK_TYPES[@]}"; do
10  echo "\nTrying: ${INSTANCE_TYPE}"
11  aws ec2 run-instances \
12    --image-id ${AMI_ID} \
13    --instance-type ${INSTANCE_TYPE} \
14    --placement AvailabilityZone=${ZONE} \
15    --count 1 2>&1
16  
17  if [ $? -eq 0 ]; then
18    echo "✓ Successfully launched ${INSTANCE_TYPE}"
19    break
20  else
21    echo "✗ No capacity for ${INSTANCE_TYPE}"
22  fi
23done

Related Errors

Provider Information

This error code is specific to AWS services. For more information, refer to the official AWS documentation.

InsufficientCapacityException - Insufficient Capacity | AWS Error Reference | Error Code Reference