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
- Provide a
user_data_filethat enables WinRM on boot. - Set
communicator = "winrm"with the correct username. - 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_usernameto the image account.
Related guides
Packer "Timeout waiting for SSH" in CIFix Packer "Timeout waiting for SSH" in CI - Packer launched the instance but could never open an SSH session…
Packer amazon-ebs subnet/VPC required in a non-default VPC in CIFix Packer amazon-ebs "VPCResourceNotSpecified" / "VPCIdNotSpecified" in CI - launching in a non-default or m…
Packer "Error waiting for instance" state timeout in CIFix Packer amazon-ebs "Error waiting for instance to become ready" in CI - the builder instance never reached…