Skip to content
Latchkey

Packer "Timeout waiting for WinRM" in CI

For Windows AMIs, Packer connects over WinRM instead of SSH. If the bootstrap user data did not enable WinRM, the security group blocks 5985/5986, or credentials are wrong, the wait times out.

What this error means

packer build prints "Waiting for WinRM to become available..." and then fails with "Timeout waiting for WinRM" for a Windows source.

packer
==> amazon-ebs.windows: Waiting for WinRM to become available...
==> amazon-ebs.windows: Timeout waiting for WinRM.
Build 'amazon-ebs.windows' errored after 10 minutes: Timeout waiting for WinRM.

Common causes

WinRM was never enabled by user data

The instance needs a bootstrap script (user_data) to enable and open WinRM. Without it, nothing listens.

Blocked ports or wrong credentials

The security group blocks 5985/5986, or the winrm_username/password does not match the image account.

How to fix it

Enable WinRM via user_data and set the communicator

  1. Provide a user_data_file that enables WinRM on boot.
  2. Set communicator = "winrm" with the correct username.
  3. Open TCP 5985/5986 in the security group.
build.pkr.hcl
source "amazon-ebs" "windows" {
  communicator   = "winrm"
  winrm_username = "Administrator"
  winrm_insecure = true
  winrm_use_ssl  = true
  user_data_file = "./bootstrap_winrm.ps1"
}

Verify the bootstrap script runs

Confirm the user data actually enables WinRM and opens the firewall on the Windows AMI you use.

How to prevent it

  • Ship a tested WinRM bootstrap script in user_data_file.
  • Open 5985/5986 in the build security group.
  • Match winrm_username to the image account.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →