EC2 instance won't start? Capacity, vCPU limits and encrypted volumes

You press Start on a stopped EC2 instance and get an error, or it sits in pending and drops straight back to stopped. Almost every case comes down to four causes. Here's how to tell which one you have, and what to do about each.

I build CostCapper, which starts and stops machines all day, so these are the failures it has to handle. The fixes below work with or without it.

First, find the reason

If the console shows an error when you start the instance, the error code is the reason. If it doesn't, and the instance goes back to stopped, ask EC2 why:

aws ec2 describe-instances --instance-ids i-1234567890abcdef0 \
  --query "Reservations[].Instances[].StateReason"

In the console, the same thing is shown as State transition reason on the instance's details. CloudTrail's event history also records each StartInstances call with any error it returned.

What you seeWhat it meansJump to
InsufficientInstanceCapacityAWS has no spare capacity for that type in that Availability Zone right now1
VcpuLimitExceeded or InstanceLimitExceededYour account's quota is used up2
Pending, then stopped, with Client.InternalError: Client error on launchUsually an encrypted volume whose KMS key you can't use3
UnauthorizedOperationThe person or role starting it lacks a permission4

1. InsufficientInstanceCapacity

AWS doesn't have enough On-Demand capacity of that instance type, in that Availability Zone, at that moment. While an instance runs, its capacity is yours. Once it's stopped, it has to find capacity again at the next start, which is why this shows up on Monday mornings for teams that switch machines off.

What to do, in order:

  • Wait a few minutes and try again. AWS's own advice, and capacity does shift often. Most of the time a retry a few minutes later works.
  • Change the instance type. A stopped, EBS-backed instance can be switched to another compatible type (Actions, Instance settings, Change instance type), for example to the next generation or a sibling family. A type with more spare capacity often starts at once.
  • Move it to another Availability Zone. A stopped instance stays in its zone. To move it, create an AMI from it and launch a new instance from that AMI in another zone. It gets a new instance ID and private IP address, so update anything that refers to them.
  • Reserve capacity, for the few that must start. An On-Demand Capacity Reservation holds capacity for a type in a zone, but you pay for it whether the instance is running or not. That cancels the saving from stopping it, so keep it for machines that genuinely can't wait.

If something starts your machines on a schedule, have it retry with a back-off and tell someone after a few failures, rather than failing once at 8 a.m. and leaving a developer to find out at 9.

2. VcpuLimitExceeded and InstanceLimitExceeded

EC2 limits how many vCPUs of On-Demand instances can run at once in each Region, per group of instance families. Starting a stopped instance counts against the same quota as launching a new one, so a team that turns several large boxes on at once can hit it even though nothing new was created. The message names your current limit, for example "You have requested more vCPU capacity than your current vCPU limit of 32 allows".

  • Check what's running in that Region: instances you forgot about use the quota too.
  • Request an increase in the Service Quotas console, under Amazon EC2, for the quota that matches the family (most general-purpose types are in "Running On-Demand Standard (A, C, D, H, I, M, R, T, Z) instances"). Small increases are often approved quickly; larger ones can take longer.

3. It starts, then goes straight back to stopped

If StateReason says Client.InternalError: Client error on launch, the usual cause is an EBS volume encrypted with a customer-managed KMS key. To start the instance, EC2 needs a grant on that key, and the grant is created with the permissions of whoever called StartInstances. Full EC2 permissions aren't enough: the caller also needs kms:CreateGrant on the key.

To confirm it, look in CloudTrail for a failed CreateGrant event at the time of the start. Then give the person or role that starts the instance something like this, with your key's ARN:

{
  "Version": "2012-10-17",
  "Statement": [{
    "Effect": "Allow",
    "Action": "kms:CreateGrant",
    "Resource": "arn:aws:kms:us-east-1:111122223333:key/YOUR-KEY-ID",
    "Condition": { "Bool": { "kms:GrantIsForAWSResource": "true" } }
  }]
}

The condition limits the grant to AWS services such as EC2 acting on your behalf. The key's own policy must also allow it, either directly or by letting IAM policies in the account decide.

The other common reason for the same symptom is Client.VolumeLimitExceeded: the account has hit its EBS volume limit. Delete unused volumes, or request an increase.

4. UnauthorizedOperation

The caller isn't allowed to start the instance. Policies that only allow starts on tagged instances are a common cause: someone renamed the tag, or the instance never had it. The error includes an encoded message; decode it to see which statement denied the call:

aws sts decode-authorization-message --encoded-message "PASTE-THE-MESSAGE"

Decoding needs the sts:DecodeAuthorizationMessage permission, which most administrators have.

Short version: read StateReason first. Capacity errors usually clear with a retry or a different instance type. Quota errors need a Service Quotas request. An instance that bounces back to stopped almost always needs kms:CreateGrant on its volume's key.