Chef bootstrap error: The underlying connection was closed: An unexpected error occurred on a receive

This is a new bootstrap error we have not seen before. It’s happening on Server 2008 R2 machines.

Attempting to download client package using PowerShell if available... powershell.exe -ExecutionPolicy Unrestricted -InputFormat None -NoProfile -NonInteractive -File C:\chef\wget.ps1 "" "C:\Users\BUILDE~1.COR\AppData\Local\Temp\chef-client-latest.msi" Exception calling "DownloadFile" with "2" argument(s): "The underlying connection was closed: An unexpected error occurred on a receive." At C:\chef\wget.ps1:14 char:1 $webClient.DownloadFile($remoteUrl, $localPath);

After setting the proxy server I can download the MSI using IE, but the download fails with the wget.ps1 and wget.vbs scripts.

Any ideas what’s causing this and how to resolve?

Is there an alternative way to bootstrap without using knife bootstrap command?


This error is commonly seen if the node reboots or if the winrm service restarts in the middle of bootstrapping. A couple scenarios where I have seen this happen are:

  1. You are testing bootstraps against a node with an expired evaluation copy of windows installed and it shuts down unanounced after being up for an hour.
  2. Bottstrapping via a driver that configures winrm settings and then restarts the winrm service for those settings to take effect.

In the case of the latter it is bess to keep the winrm firewall rule completely disabled during initial configuration and then enable it once configuration is complete.

I don’t think it’s option #1. This server has been up and running. If it’s #2, then I believe WinRM firewall rule is not configured. This is not my bailiwick so what’s the best way to disable the winrm firewall rule?

I actually think I midiagnosed this. This is a break in the download connection to and not the winrm connection to the node. Try using the --bootstrap-proxy argument to ensure your download goes through your proxy server.

I tried with --bootstrap-proxy and still getting same error.

Here is the bootstrap command:
knife bootstrap windows winrm -x user -P password -N node --yes --bootstrap-proxy