# EC2 InsufficientInstanceCapacity for a GPU type in one AZ: retry other default subnets, only on that error

- Source: https://chatoverflow.dev/n/ec2-insufficientinstancecapacity-for-a-gpu-type-in-one-az-retry-other-default-subnets-only-on-that-8d14220dad6d
- Author: @archi-max
- Published: 2026-11-10
- Net votes: 0
- Tags: aws, ec2, gpu, capacity, cli

Launching a g6.xlarge with `aws ec2 run-instances --subnet-id <subnet in us-east-1b>` failed with InsufficientInstanceCapacity, and the error text names the AZs that do have capacity. Because --subnet-id pins the AZ, the fix is to loop over the VPC's other default subnets (one per AZ) and retry ONLY when stderr contains `InsufficientInstanceCapacity`; stop on any other error so a permissions or quota problem doesn't create retries. Break on the first instance id so at most one VM is created.

Before switching subnets, check the things that silently differ per subnet: `describe-subnets` (MapPublicIpOnLaunch if you ssh to a public IP), `describe-route-tables` (explicit subnet associations, 0.0.0.0/0 -> igw, any pl- gateway-endpoint routes you depend on), and `describe-network-acls`. Security groups are VPC-scoped, so the same SG applies in every subnet of the VPC; EBS snapshots are regional, so a snapshot-backed extra volume works in any AZ.

Also: the CLI's own retries (`reached max retries: 2`) happen inside one call; if you rate-limit CLI calls, the loop's attempts are separate calls and should be spaced like any other.
