hashicorp/packer · error

Timeout waiting for machine to restart.

Error message

Timeout waiting for machine to restart.

What it means

After initiating the restart, the provisioner polls the guest with a restart_check_command and waits for the communicator to become available again, bounded by restart_timeout (default 5m). If the machine does not come back within that window, the timeout channel fires, the provisioner cancels its internal waiter and returns this error, failing the build.

Source

Thrown at provisioner/windows-restart/provisioner.go:199

	log.Printf("Waiting for machine to reboot with timeout: %s", p.config.RestartTimeout)

WaitLoop:
	for {
		// Wait for either WinRM to become available, a timeout to occur,
		// or an interrupt to come through.
		select {
		case <-waitDone:
			if err != nil {
				ui.Error(fmt.Sprintf("Error waiting for machine to restart: %s", err))
				return err
			}

			ui.Say("Machine successfully restarted, moving on")
			close(p.cancel)
			break WaitLoop
		case <-timeout:
			err := fmt.Errorf("Timeout waiting for machine to restart.")
			ui.Error(err.Error())
			close(p.cancel)
			return err
		case <-p.cancel:
			close(waitDone)
			return fmt.Errorf("Interrupt detected, quitting waiting for machine to restart")
		}
	}
	return nil

}

var waitForCommunicator = func(ctx context.Context, p *Provisioner) error {
	runCustomRestartCheck := true
	if p.config.RestartCheckCommand == DefaultRestartCheckCommand {
		runCustomRestartCheck = false
	}
	// This command is configurable by the user to make sure that the

View on GitHub (pinned to eb36e3c3e4)

Solutions

  1. Increase restart_timeout in the windows-restart provisioner block (e.g. "15m")
  2. Verify the guest actually comes back up and WinRM is reachable after reboot (winrm service auto-start, firewall rules)
  3. Customize restart_check_command if the default probe mis-detects reboot state
  4. Check guest console logs/screenshots (e.g. via hypervisor) for boot failures
  5. If Windows updates cause long reboots, pre-install updates in the image before the restart step

Example fix

// before
provisioner "windows-restart" {
  restart_timeout = "5m"
}
// after
provisioner "windows-restart" {
  restart_timeout = "15m"
}
Defensive patterns

Strategy: retry

Validate before calling

provisioner "windows-restart" {
  restart_timeout       = "15m"
  # ensure the check command matches your environment
  restart_check_command = ["powershell", "-command", "..."]
}

Prevention

When it happens

Trigger: waitForCommunicator cannot re-establish WinRM/SSH within restart_timeout because the guest is stuck rebooting, booting slowly, or networking/DHCP issues keep the communicator unreachable.

Common situations: Windows updates during reboot extending boot time well beyond 5 minutes; guest stuck at boot repair/BSOD; changed IP after reboot with no static addressing; WinRM service slow to start; large on-prem machines with slow storage.

Understand the failure class

Related errors


AI-assisted analysis of hashicorp/packer@eb36e3c3e4 (2026-09-05). Data as JSON: /api/errors/d096d388b8262ea3. Report an issue: GitHub.