Vagrant: HTTPClient::KeepAliveDisconnected: An existing connection was forcibly closed by the remote host

Created on 23 Oct 2015  ยท  18Comments  ยท  Source: hashicorp/vagrant

| Host OS | OS X, Windows 10 Enterprise |
| --- | --- |
| Guest OS | Windows 10 Enterprise |
| Vagrant | 1.7.4 |
| VirtualBox | 5.0.4 |
| Provider | virtualbox |

Vagrantfile:

Vagrant.configure(2) do |config|
  config.vm.box = "custom"
  config.vm.guest = :windows
  config.vm.communicator = "winrm"
  config.winrm.username = "vagrant"
  config.winrm.password = "vagrant"
  config.winrm.max_tries = 20
  config.vm.network :forwarded_port, guest: 3389, host: 3389
  config.vm.network :forwarded_port, guest: 5985, host: 5985, id: "winrm", auto_correct: true

  config.vm.provider "virtualbox" do |vb|
     vb.name = "custom"
     vb.gui = true
     vb.customize ["modifyvm", :id, "--memory", "2048"]
     vb.customize ["modifyvm", :id, "--vram", "256"]
  end

  config.vm.provision :shell, path: "./ps/Install-Chocolatey.ps1"
  config.vm.provision :shell, path: "./ps/InstallApps.ps1"
end

Preparation:

  • Firewall is turned off on host and guest machines, anyway ports were opened manually:
netsh advfirewall firewall add rule name="5985" dir=in action=allow protocol=TCP localport=5985
netsh advfirewall firewall add rule name="3389" dir=in action=allow protocol=TCP localport=3389
  • Enabled private networking :
Set-NetConnectionProfile -InterfaceAlias Ethernet -NetworkCategory Private
  • WinRM service and client configured next way:
winrm quickconfig -q
winrm set winrm/config/winrs '@{MaxMemoryPerShellMB="512"}'
winrm set winrm/config '@{MaxTimeoutms="1800000"}'
winrm set winrm/config/service '@{AllowUnencrypted="true"}'
winrm set winrm/config/service/auth '@{Basic="true"}'
sc config "WinRM" start=auto

Export:

$path = "F:\custom" 
vagrant package --base custom --output $path/custom.box --vagrantfile $path/Vagrantfile
vagrant box add custom.box --name custom

Result:

F:\custom> vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'custom.box'...
==> default: Matching MAC address for NAT networking...
==> default: Setting the name of the VM: custom_default_1445570609823_89912
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
==> default: Forwarding ports...
    default: 3389 => 3389 (adapter 1)
    default: 5985 => 5985 (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: WinRM address: 127.0.0.1:5985
    default: WinRM username: vagrant
    default: WinRM transport: plaintext
An error occurred executing a remote WinRM command.

Shell: powershell
Command: hostname
if ($?) { exit 0 } else { if($LASTEXITCODE) { exit $LASTEXITCODE } else { exit 1
 } }
Message: HTTPClient::KeepAliveDisconnected: An existing connection was forcibly
closed by the remote host.

vagrant up on Windows host : https://gist.github.com/mskutin/3c57928ff608f8ad7991
vagrant up on OS X host : https://gist.github.com/mskutin/fad15bba67032b6f7745

The VM is starting but WinRM is unable to connect due to exception above.

bug gueswindows hoswindows

Most helpful comment

I know the issue is closed, but I came across this problem with a Windows 7 guest with a Windows 10 host. The guest was downloaded from the Microsoft Modern.ie site with IE10. I found that the Windows Remote Management service was on a delayed start, change from "Automatic (Delayed Start)" to "Automatic" and seems to have resolved my issue.

All 18 comments

Same issue with Windows 7 as guest and host OS. Error message:

An error occurred executing a remote WinRM command.

Shell: powershell
Command: hostname
if ($?) { exit 0 } else { if($LASTEXITCODE) { exit $LASTEXITCODE } else { exit 1 } }
Message: HTTPClient::KeepAliveDisconnected: Broken pipe

Same issue here, with Windows 10 Professional. My vagrant file is:

Vagrant.configure(2) do |config|
  config.vm.guest = :windows
  config.vm.communicator = "winrm"
  config.winrm.username = "robot"
  config.winrm.password = "robot"
  config.vm.boot_timeout = 6000
  config.vm.graceful_halt_timeout = 6000

  # Create a forwarded port mapping which allows access to a specific port
  # within the machine from a port on the host machine. In the example below,
  # accessing "localhost:8080" will access port 80 on the guest machine.
  # config.vm.network "forwarded_port", guest: 80, host: 8080
  config.vm.network :forwarded_port, guest: 54473, host: 1234
  #config.vm.network :forwarded_port, guest: 3389, host: 3389
  config.vm.network :forwarded_port, guest: 5985, host: 5985, id: "winrm", auto_correct: true

  config.vm.provider "virtualbox" do |vb|
  # Customize the name of VM in VirtualBox manager UI:
    vb.name = "BJSS.DevEnvNew"
    #vb.gui = true
    #v.customize ["modifyvm", :id, "--memory", 2048]
    #v.customize ["modifyvm", :id, "--cpus", 2]
    #v.customize ["setextradata", "global", "GUI/SuppressMessages", "all" ]
  end

  config.vm.box = "BJSS.DevEnv.box"
  config.vm.provision :shell, :path => "setup_requirements.cmd"

  config.vm.provision :shell, inline: "cinst java.jdk puppet"
  config.vm.provision :shell, inline: "puppet module install --force rismoney/chocolatey"

  config.vm.provision :puppet do |puppet|
    puppet.manifests_path = ""
    puppet.manifest_file  = "base.pp"
  end
end

The box was preparred using this tutorial: http://huestones.co.uk/node/305

I'm updated the vagrant to version 1.8.1. But still have no success with run Windows guest in Windows host:

    default: Adapter 1: nat
==> default: Forwarding ports...
    default: 5985 (guest) => 55985 (host) (adapter 1)
    default: 5986 (guest) => 55986 (host) (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: WinRM address: 127.0.0.1:55985
    default: WinRM username: vagrant
    default: WinRM execution_time_limit: 6h
    default: WinRM transport: plaintext
An error occurred executing a remote WinRM command.

Shell: powershell
Command: $ProgressPreference='SilentlyContinue';
hostname
if ($?) { exit 0 } else { if($LASTEXITCODE) { exit $LASTEXITCODE } else { exit 1 } }
Message: HTTPClient::KeepAliveDisconnected: An established connection was aborted by the software in your host machine. @ io_fillbuf - fd:7

@sethvargo, @mskutin for me this issue is fixed by using additional options:

  config.winrm.retry_limit = 30
  config.winrm.retry_delay = 10

Thanks to this explanation in WinRb documentation. Somebody can confirm this?

@rhiann0n can you show you're Vagrantfile?

@rrzaripov Unfortunately your suggestion didn't help me, I believe something wrong with the box I have prepared.

@mskutin I'm using veewee for preparing boxes. There are no template for Windows 10 now, but possible will use template for Windows 7-8 as a start point.

@rrzaripov thanks, didn't know about veewee, I'll have a look whenever I need to use vagrant again.

https://github.com/mitchellh/vagrant/issues/6430#issuecomment-184097261 did not fix it for me. I do not have this problem when the host is MacOS, but I am having this problem when the host is Ubuntu 16.04.

@johnjelinek after more deep learning about how works WinRM and the Windows firewall, I'm also confirm, that it is not solution. This parameters not required for proper connection via WinRM. For me issue is gone after next steps:

  • Using veewee for preconfiguring the Windows.
  • Opening WinRM ports in firewall for public networks (detailed here). This not necessary, but needed in my case, because my network is not in domain. By default WinRM ports opened to communicate only over domain network.

In your case vagrant, virtualbox and box versions are same?

@rrzaripov: I just ran vagrant on a new win10 vm (https://developer.microsoft.com/en-us/microsoft-edge/tools/vms/mac/). After I Set-NetConnectionProfile to make the interface Private (it defaulted to Public) and configured wirnm, it started to work. Then I did a vagrant reload and now I only get the error message you have:

An error occurred executing a remote WinRM command.

Shell: powershell
Command: $ProgressPreference='SilentlyContinue';
hostname
if ($?) { exit 0 } else { if($LASTEXITCODE) { exit $LASTEXITCODE } else { exit 1 } }
Message: HTTPClient::KeepAliveDisconnected:

It may be unrelated but this issue might help: https://github.com/boxcutter/windows/issues/51
In my case, if I do a first vagrant upย I get the error, then if I do a vagrant reload everything is fine. Using the trick indicated in the issue when building the box solves the problem for me.

@dbroeglin vagrant up; vagrant reload works for me 2.

+1

Followed this guide: http://huestones.co.uk/node/305 + disable firewall in VM
Host machine running OS X 10.10.3.

Error:

An error occurred executing a remote WinRM command.

Shell: powershell
Command: $ProgressPreference='SilentlyContinue';
hostname
if ($?) { exit 0 } else { if($LASTEXITCODE) { exit $LASTEXITCODE } else { exit 1 } }
Message: HTTPClient::KeepAliveDisconnected: Connection reset by peer @ io_fillbuf - fd:21

Update
I added this to the Vagrantfile i use to package the box as @rrzaripov mentioned in his comment.

  config.winrm.retry_limit = 30
  config.winrm.retry_delay = 10

And then rebuild the entire box.

And now it's working!

Hi there,

Thanks for reporting this bug. I'm sure this was a real issue when originally reported (our fault for not looking sooner!) but there have been multiple Vagrant releases since the original report. I'm going to close this issue now and request you reopen the issue if you're still experiencing this problem. I'm sorry this wasn't looked at earlier :frowning_face:

Cheers!

i had the same issue. what i did to fix it was:
$ vagrant up
//open another terminal
$ virtualbox
//'show' the running vm

I know the issue is closed, but I came across this problem with a Windows 7 guest with a Windows 10 host. The guest was downloaded from the Microsoft Modern.ie site with IE10. I found that the Windows Remote Management service was on a delayed start, change from "Automatic (Delayed Start)" to "Automatic" and seems to have resolved my issue.

I'm going to lock this issue because it has been closed for _30 days_ โณ. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

DreadPirateShawn picture DreadPirateShawn  ยท  3Comments

hesco picture hesco  ยท  3Comments

mpontillo picture mpontillo  ยท  3Comments

lebogan picture lebogan  ยท  3Comments

jsirex picture jsirex  ยท  3Comments