{"record":{"id":"d096d388b8262ea3","repo":"hashicorp/packer","slug":"timeout-waiting-for-machine-to-restart","errorCode":null,"errorMessage":"Timeout waiting for machine to restart.","messagePattern":"Timeout waiting for machine to restart\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"provisioner/windows-restart/provisioner.go","lineNumber":199,"sourceCode":"\n\tlog.Printf(\"Waiting for machine to reboot with timeout: %s\", p.config.RestartTimeout)\n\nWaitLoop:\n\tfor {\n\t\t// Wait for either WinRM to become available, a timeout to occur,\n\t\t// or an interrupt to come through.\n\t\tselect {\n\t\tcase <-waitDone:\n\t\t\tif err != nil {\n\t\t\t\tui.Error(fmt.Sprintf(\"Error waiting for machine to restart: %s\", err))\n\t\t\t\treturn err\n\t\t\t}\n\n\t\t\tui.Say(\"Machine successfully restarted, moving on\")\n\t\t\tclose(p.cancel)\n\t\t\tbreak WaitLoop\n\t\tcase <-timeout:\n\t\t\terr := fmt.Errorf(\"Timeout waiting for machine to restart.\")\n\t\t\tui.Error(err.Error())\n\t\t\tclose(p.cancel)\n\t\t\treturn err\n\t\tcase <-p.cancel:\n\t\t\tclose(waitDone)\n\t\t\treturn fmt.Errorf(\"Interrupt detected, quitting waiting for machine to restart\")\n\t\t}\n\t}\n\treturn nil\n\n}\n\nvar waitForCommunicator = func(ctx context.Context, p *Provisioner) error {\n\trunCustomRestartCheck := true\n\tif p.config.RestartCheckCommand == DefaultRestartCheckCommand {\n\t\trunCustomRestartCheck = false\n\t}\n\t// This command is configurable by the user to make sure that the","sourceCodeStart":181,"sourceCodeEnd":217,"githubUrl":"https://github.com/hashicorp/packer/blob/eb36e3c3e48a036f3e8cc94087636ee72e1303c9/provisioner/windows-restart/provisioner.go#L181-L217","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Increase restart_timeout in the windows-restart provisioner block (e.g. \"15m\")","Verify the guest actually comes back up and WinRM is reachable after reboot (winrm service auto-start, firewall rules)","Customize restart_check_command if the default probe mis-detects reboot state","Check guest console logs/screenshots (e.g. via hypervisor) for boot failures","If Windows updates cause long reboots, pre-install updates in the image before the restart step"],"exampleFix":"// before\nprovisioner \"windows-restart\" {\n  restart_timeout = \"5m\"\n}\n// after\nprovisioner \"windows-restart\" {\n  restart_timeout = \"15m\"\n}","handlingStrategy":"retry","validationCode":"provisioner \"windows-restart\" {\n  restart_timeout       = \"15m\"\n  # ensure the check command matches your environment\n  restart_check_command = [\"powershell\", \"-command\", \"...\"]\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Size restart_timeout to exceed the guest's worst-case reboot/update time","Confirm WinRM auto-starts and firewall allows it after reboot","Watch guest console output for boot failures (BSOD, boot repair)","Use static/expected addressing or DHCP reservation so the host stays reachable"],"tags":["provisioner","windows-restart","timeout","reboot","windows"],"backgroundTag":"restart-timeout","analyzedSha":"eb36e3c3e48a036f3e8cc94087636ee72e1303c9","analyzedAt":"2026-09-05T13:20:43.127Z","contentChangedAt":"2026-09-05T13:20:43.127Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}