Vagrant: Starting a VM with Vagrant 1.4.3 on Windows 8.1 fails sometimes with a connection error

Created on 26 Feb 2014  ยท  18Comments  ยท  Source: hashicorp/vagrant

Sometimes vagrant up fails with a connection error, reporting some problems regarding ports. The weird thing is that if it happens, it repeatedly fails when trying to call vagrant reload, even multiple times.

I've figured out that it may be related to software running on the host machine (Windows 8.1) which uses a lot of ports, for example Spotify. When I have Spotify running and encounter the mentioned problem, after I close Spotify the next vagrant reload succeeds.

Unfortunately I have no error log at the moment, but thought I report this anyway.

Is this a known error?

I'll add the error message/log as soon as it happens again.

Most helpful comment

I'm not sure if I should open a new issue or comment here since it's related, please apologize if I'm reporting in the wrong place.

I'm on Windows 10 and today I upgraded to Vagrant 1.9.3 from an older version (I also upgraded Virtualbox if it could be related), and after the update the port forwarding stopped working on both the ports I have configured in the Vagrantfile of my VM. While searching for a solution I found this issue, old but similar to mine. Only difference is that instead of Errno::EACCES i was getting Errno::EADDRNOTAVAIL.
The message said Indirizzo richiesto non valido nel proprio contesto. - connect(2) for "0.0.0.0" port 5432 (my Windows installation is in Italian, the first string roughly translates to The requested address is not valid in its context ).
I'm quite sure I haven't anything on the host listening on those ports.
After reading the discussion I solved in the same way, I added Errno::EADDRNOTAVAIL too at line 33 of C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.9.3/lib/vagrant/util/is_port_open.rb and now everything is working, however I never touched a line of Ruby before and I don't know about Vagrant internals so I have no idea if this workaround makes sense.

I reported this so you could have a look if the file in the upstream needs to be changed too and for reference for people having the same problem.

All 18 comments

I switched to using Windows 8.1 full time this year and Vagrant has been working fine. Please attach log/output of what is happening and maybe I can help.

@mitchellh I got the error message now, but still no debug trace, because the 2nd vagrant up worked after the initial fail.

Here's the output:

`Bringing machine 'default' up with 'virtualbox' provider...
[default] Clearing any previously set forwarded ports...
[default] The cookbook path 'S:/Project/streamly.hub/.chef/databag' doesn't exist. Ignoring...
C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.4.3/lib/vagrant/util/is_port_open.rb:21:in `initialize': Permission denied - connect(2) (Errno::EACCES)
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.4.3/lib/vagrant/util/is_port_open.rb:21:in `new'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.4.3/lib/vagrant/util/is_port_open.rb:21:in `block in is_port_open?'
        from C:/HashiCorp/Vagrant/embedded/lib/ruby/2.0.0/timeout.rb:66:in `timeout'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.4.3/lib/vagrant/util/is_port_open.rb:19:in `is_port_open?'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.4.3/lib/vagrant/action/builtin/handle_forwarded_port_collisions.rb:72:in `block in call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.4.3/lib/vagrant/action/builtin/handle_forwarded_port_collisions.rb:128:in `block in with_forwarded_ports'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.4.3/lib/vagrant/action/builtin/handle_forwarded_port_collisions.rb:124:in `each'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.4.3/lib/vagrant/action/builtin/handle_forwarded_port_collisions.rb:124:in `with_forwarded_ports'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.4.3/lib/vagrant/action/builtin/handle_forwarded_port_collisions.rb:61:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.4.3/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.4.3/plugins/providers/virtualbox/action/prepare_forwarded_port_collision_params.rb:30:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.4.3/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.4.3/lib/vagrant/action/builtin/env_set.rb:19:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.4.3/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.4.3/lib/vagrant/action/builtin/provision.rb:52:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.4.3/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.4.3/plugins/providers/virtualbox/action/clear_forwarded_ports.rb:13:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.4.3/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.4.3/plugins/providers/virtualbox/action/set_name.rb:48:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.4.3/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.4.3/plugins/providers/virtualbox/action/clean_machine_folder.rb:17:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.4.3/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.4.3/plugins/providers/virtualbox/action/check_accessible.rb:18:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.4.3/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.4.3/lib/vagrant/action/warden.rb:95:in `block in finalize_action'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.4.3/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.4.3/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.4.3/lib/vagrant/action/builder.rb:116:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.4.3/lib/vagrant/action/runner.rb:69:in `block in run'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.4.3/lib/vagrant/util/busy.rb:19:in `busy'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.4.3/lib/vagrant/action/runner.rb:69:in `run'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.4.3/lib/vagrant/action/builtin/call.rb:51:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.4.3/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.4.3/lib/vagrant/action/warden.rb:95:in `block in finalize_action'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.4.3/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.4.3/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.4.3/lib/vagrant/action/builder.rb:116:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.4.3/lib/vagrant/action/runner.rb:69:in `block in run'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.4.3/lib/vagrant/util/busy.rb:19:in `busy'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.4.3/lib/vagrant/action/runner.rb:69:in `run'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.4.3/lib/vagrant/action/builtin/call.rb:51:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.4.3/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.4.3/lib/vagrant/action/warden.rb:95:in `block in finalize_action'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.4.3/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.4.3/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.4.3/lib/vagrant/action/builder.rb:116:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.4.3/lib/vagrant/action/runner.rb:69:in `block in run'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.4.3/lib/vagrant/util/busy.rb:19:in `busy'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.4.3/lib/vagrant/action/runner.rb:69:in `run'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.4.3/lib/vagrant/action/builtin/call.rb:51:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.4.3/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.4.3/lib/vagrant/action/builtin/config_validate.rb:25:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.4.3/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.4.3/plugins/providers/virtualbox/action/check_virtualbox.rb:17:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.4.3/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.4.3/lib/vagrant/action/builtin/call.rb:57:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.4.3/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.4.3/lib/vagrant/action/builtin/config_validate.rb:25:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.4.3/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.4.3/lib/vagrant/action/builtin/call.rb:57:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.4.3/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.4.3/plugins/providers/virtualbox/action/check_virtualbox.rb:17:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.4.3/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.4.3/lib/vagrant/action/builder.rb:116:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.4.3/lib/vagrant/action/runner.rb:69:in `block in run'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.4.3/lib/vagrant/util/busy.rb:19:in `busy'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.4.3/lib/vagrant/action/runner.rb:69:in `run'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.4.3/lib/vagrant/machine.rb:147:in `action'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.4.3/lib/vagrant/batch_action.rb:63:in `block (2 levels) in run'

Any updates on this? I'm getting a very similar issue, no Spotify though.

This happens pretty often for me now. Hopefully I'll have some time to catch a full debug log soon.

@mitchellh, @berniedurfee I was finally able to catch a debug log when the error was occuring:
https://gist.github.com/thasmo/144a17542d2537c52391

@mitchellh, any idea what's going on? It only happens sporadically, but always when I have Spotify opened, which probably uses a lot of ports for P2P.

Potentially we need to additionally catch Errno::EACCES here. Can you try modifying (C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.6.3/lib/vagrant/util/is_port_open.rb) and see if you get any further?

@sneal, do I have to change the line to:
rescue Timeout::Error, Errno::ECONNREFUSED, Errno::EHOSTUNREACH, Errno::ENETUNREACH, Errno::EACCES?

@thasmo Yes.

Thanks. Just to clarify, should this potentionally fix it or give more debug information, @sneal?

@thasmo Hopefully fix the issue.

This issue still happens to me and my coworkers up to the latest Vagrant 1.7.2, 100% of the times that we do a vagrant up. Adding Errno::EACCES to the rescue line at is_port_open.rb fixes the issue to us with no other impact that we can tell. The cause might be a permissions issue with the Windows corporate image or domain policies. It would be great to have this fix committed to the master branch

@aromanos Thanks for confirming the fix!

I'm not sure if I should open a new issue or comment here since it's related, please apologize if I'm reporting in the wrong place.

I'm on Windows 10 and today I upgraded to Vagrant 1.9.3 from an older version (I also upgraded Virtualbox if it could be related), and after the update the port forwarding stopped working on both the ports I have configured in the Vagrantfile of my VM. While searching for a solution I found this issue, old but similar to mine. Only difference is that instead of Errno::EACCES i was getting Errno::EADDRNOTAVAIL.
The message said Indirizzo richiesto non valido nel proprio contesto. - connect(2) for "0.0.0.0" port 5432 (my Windows installation is in Italian, the first string roughly translates to The requested address is not valid in its context ).
I'm quite sure I haven't anything on the host listening on those ports.
After reading the discussion I solved in the same way, I added Errno::EADDRNOTAVAIL too at line 33 of C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.9.3/lib/vagrant/util/is_port_open.rb and now everything is working, however I never touched a line of Ruby before and I don't know about Vagrant internals so I have no idea if this workaround makes sense.

I reported this so you could have a look if the file in the upstream needs to be changed too and for reference for people having the same problem.

thnx for me its work!

I can confirm the issue happens to me also in Windows 7 / VirtualBox 5.1.18r114002. It was solved with the change proposed by @gianluca-nitti

I was facing the same problem on Windows 10, VirtualBox 5.1.18 and vagrant 1.9.3. The problem was resolved by applying the changes suggested by @gianluca-nitti. Thank you!

Same problem here while enabling port forwarding on Windows 10, VBox 5.1.18 and Vagrant 1.9.3; fixed by @gianluca-nitti solution.

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

jsirex picture jsirex  ยท  3Comments

tomhking picture tomhking  ยท  3Comments

DreadPirateShawn picture DreadPirateShawn  ยท  3Comments

lebogan picture lebogan  ยท  3Comments

rhencke picture rhencke  ยท  3Comments