Reputation: 51
So here's my problem. I used Vagrant to install a virtual machine on my Mac.
When I run vagrant up
I get this output
$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'geerlingguy/ubuntu1604'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'geerlingguy/ubuntu1604' is up to date...
==> default: Setting the name of the VM: <name>
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
==> default: Forwarding ports...
default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 127.0.0.1:2222
default: SSH username: vagrant
default: SSH auth method: private key
Timed out while waiting for the machine to boot. This means that
Vagrant was unable to communicate with the guest machine within
the configured ("config.vm.boot_timeout" value) time period.
If you look above, you should be able to see the error(s) that
Vagrant had when attempting to connect to the machine. These errors
are usually good hints as to what may be wrong.
If you're using a custom box, make sure that networking is properly
working and you're able to connect to the machine. It is a common
problem that networking isn't setup properly in these boxes.
Verify that authentication configurations are also setup properly,
as well.
If the box appears to be booting properly, you may want to increase
the timeout ("config.vm.boot_timeout") value.
Running vagrant status
, however, shows that the box is up and running. When I try to vagrant ssh
into the box, it hangs for a while then exits with
ssh_exchange_identification: Connection closed by remote host
Finally, booting the machine in GUI mode allows me to successfully log in. Now, having played with this for a while I have noticed the following.
Running lsof -i 2222
shows that the port is not actually being forwarded as it should be.
VirtualBo 38361 <user> 29u IPv4 <device> 0t0 TCP localhost:2222 (LISTEN)
Running ifconfig
in the guest machine shows no IP address for the box, only a hardware address.
When I tried increasing the Vagrant timeout as per the error message's suggestion (to 3600s = 1h), lsof
showed that the port kept getting forwarded, broken with message (CLOSED_WAIT), then re-forwarded to another port, over and over and over again so that vagrant up
had to be manually stopped with ctl-C.
VirtualBo 38361 <user> 29u IPv4 <device> 0t0 TCP localhost:rockwell-csp2 (LISTEN)
VirtualBo 38361 <user> 30u IPv4 <device> 0t0 TCP localhost:rockwell-csp2->localhost:61746 (CLOSE_WAIT)
VirtualBo 38361 <user> 31u IPv4 <device> 0t0 TCP localhost:rockwell-csp2->localhost:61750 (CLOSE_WAIT)
VirtualBo 38361 <user> 32u IPv4 <device> 0t0 TCP localhost:rockwell-csp2->localhost:61753 (CLOSE_WAIT)
VirtualBo 38361 <user> 30u IPv4 <device> 0t0 TCP localhost:rockwell-csp2->localhost:61746 (CLOSE_WAIT)
VirtualBo 38361 <user> 18u IPv4 <device> 0t0 TCP localhost:rockwell-csp2->localhost:61748 (CLOSE_WAIT)
VirtualBo 38361 <user> 29u IPv4 <device> 0t0 TCP localhost:rockwell-csp2 (LISTEN)
VirtualBo 38361 <user> 30u IPv4 <device> 0t0 TCP localhost:rockwell-csp2->localhost:61746 (CLOSE_WAIT)
VirtualBo 38361 <user> 31u IPv4 <device> 0t0 TCP localhost:rockwell-csp2->localhost:61750 (CLOSE_WAIT)
VirtualBo 38361 <user> 32u IPv4 <device> 0t0 TCP localhost:rockwell-csp2->localhost:61753 (CLOSE_WAIT)]
etc.
Many thanks for the suggestions, 'cause this has been driving me nuts for days.
Upvotes: 2
Views: 800
Reputation: 51
I figured it out!
The issue was that my VMs were trying to connect to the NAT adapter in VirtualBox (adapter 1), but by default adapter 1 was disconnected. After reading this GitHub issue thread (https://github.com/mitchellh/vagrant/issues/7648) I added
config.vm.provider 'virtualbox' do |vb|
vb.customize ['modifyvm', :id, '--cableconnected1', 'on']
end
and the VM started up just fine. I was working on this issue for DAYS!
Upvotes: 3