Skip to content
Latchkey

Packer "Error waiting for instance" state timeout in CI

After launching, Packer polls until the instance reaches a ready state. If capacity, a bad AMI, or a startup failure prevents it, the poll times out and the build aborts.

What this error means

packer build fails with "Error waiting for instance (i-...) to become ready" or a state timeout after the instance was launched.

packer
==> amazon-ebs.ubuntu: Error waiting for instance (i-0123456789abcdef0) to become
ready: timeout while waiting for state to become 'running' (last state: 'pending')

Common causes

Capacity or a stuck pending state

The instance stays in pending, sometimes from a capacity issue or an instance type that cannot launch in the chosen subnet.

A short state timeout for a slow region

The default wait is too short for a slow-starting instance in a busy region.

How to fix it

Use an available instance type and subnet

  1. Check that the instance type is offered in the target Availability Zone.
  2. Choose a subnet in an AZ with capacity for that type.
  3. Re-run the build.

Raise the state timeout

Give the instance more time to reach the running state before Packer gives up.

build.pkr.hcl
source "amazon-ebs" "ubuntu" {
  aws_polling {
    delay_seconds = 15
    max_attempts  = 80
  }
}

How to prevent it

  • Pick instance types available in the chosen AZ.
  • Raise aws_polling limits for slow regions.
  • Alert on repeated pending-state timeouts in the account.

Frequently asked questions

What causes ""Error waiting for instance""?
The instance stays in pending, sometimes from a capacity issue or an instance type that cannot launch in the chosen subnet.
How do I fix "Error waiting for instance"?
Use an available instance type and subnet

Related guides

References

Run this faster and cheaper on Latchkey managed runners - self-healing included. Start free → 30-day trial · No credit card