Vagrant: Debug Slow Starting VM - vagrant

I'm using vagrant to setup a virtual environment on a programming project. Virtual Box is the VM provider. I'm working on a Windows workstation. This is borderline server fault territory -- but since I'm using vagrant to setup an environment for a programming project I'm asking on Stack Overflow.
When I run
vagrant up
Vagrant can take "a long time" (up to 5 minutes) to start the virtual machine. From my side (starting vagrant from a "Git Bash" shell) I see this
default: SSH auth method: private key
default: Warning: Connection timeout. Retrying...
default: Warning: Remote connection disconnect. Retrying...
default: Warning: Remote connection disconnect. Retrying...
default: Warning: Remote connection disconnect. Retrying...
default: Warning: Remote connection disconnect. Retrying...
default: Warning: Remote connection disconnect. Retrying...
default: Warning: Remote connection disconnect. Retrying...
default: Warning: Remote connection disconnect. Retrying...
default: Warning: Remote connection disconnect. Retrying...
default: Warning: Remote connection disconnect. Retrying...
default: Warning: Remote connection disconnect. Retrying...
default: Warning: Remote connection disconnect. Retrying...
default: Warning: Remote connection disconnect. Retrying...
default: Warning: Remote connection disconnect. Retrying...
default: Warning: Remote connection disconnect. Retrying...
default: Warning: Remote connection disconnect. Retrying...
default: Warning: Remote connection disconnect. Retrying...
default: Warning: Remote connection disconnect. Retrying...
default: Warning: Remote connection disconnect. Retrying...
This continues for a while, and the server eventually comes up. Also, occasionally, the SSH connection will die between 12 - 24 hours after I do a vgrant up -- this forces a halt -f/re-up.
If I start the machine from Virtual Box itself, here's the relevant section of the start up routine.
The halting seems to happen when this screen reads
Waiting 10 Seconds for a Network Device
Waiting 120 Seconds for a Network Device
This seems abnormal (and certainly annoying) behavior and I'd like to debug why it's happening -- However, I'm not familiar enough with the workings of vagarnt or virtual machines to know where I should start. I'd love a magic solution to my problem, but all I'm really after is "where do I start digging"

Related

Mac | homestead: Warning: Remote connection disconnect. Retrying

After adding dnsmasq in mac, I am getting below error in vagrant,
nat: Warning: Remote connection disconnect. Retrying...
nat: Warning: Remote connection disconnect. Retrying...
nat: Warning: Remote connection disconnect. Retrying...
nat: Warning: Remote connection disconnect. Retrying...
nat: Warning: Remote connection disconnect. Retrying...
nat: Warning: Remote connection disconnect. Retrying...
nat: Warning: Remote connection disconnect. Retrying...
nat: Warning: Remote connection disconnect. Retrying...
nat: Warning: Remote connection disconnect. Retrying...
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.
Fixed,
After destroying vagrant and installing again it's working properly.
vagrant destroy

Vagrant Up VAB: Warning: Remote connection disconnect. Retrying

Anyone know what is going on with Vagrant?
Using Windows 10, VScode, Virtualbox 6.1.10
i have done googling and not found anything helpful
one person said to Use config.ssh.insert_key = false in your Vagrantfile and then try.
but doing so did not work (or not sure where to put it in my vagrantfile)
VAB: Booting VM...
==> VAB: Waiting for machine to boot. This may take a few minutes...
VAB: SSH address: 127.0.0.1:2222
VAB: SSH username: vagrant
VAB: SSH auth method: private key
VAB: Warning: Remote connection disconnect. Retrying...
VAB: Warning: Remote connection disconnect. Retrying...
VAB: Warning: Remote connection disconnect. Retrying...
VAB: Warning: Remote connection disconnect. Retrying...
VAB: Warning: Remote connection disconnect. Retrying...
VAB: Warning: Remote connection disconnect. Retrying...
VAB: Warning: Remote connection disconnect. Retrying...
VAB: Warning: Remote connection disconnect. Retrying...
VAB: Warning: Remote connection disconnect. Retrying...
VAB: Warning: Remote connection disconnect. Retrying...
VAB: Warning: Remote connection disconnect. Retrying...
VAB: Warning: Remote connection disconnect. Retrying...
VAB: Warning: Remote connection disconnect. Retrying...
VAB: Warning: Remote connection disconnect. Retrying...
VAB: Warning: Remote connection disconnect. Retrying...
VAB: Warning: Remote connection disconnect. Retrying...
VAB: Warning: Remote connection disconnect. Retrying...
VAB: Warning: Remote connection disconnect. Retrying...
VAB: Warning: Remote connection disconnect. Retrying...
VAB: Warning: Remote connection disconnect. Retrying...
VAB: Warning: Remote connection disconnect. Retrying...
VAB: Warning: Remote connection disconnect. Retrying...
VAB: Warning: Remote connection disconnect. Retrying...
VAB: Warning: Remote connection disconnect. Retrying...
VAB: Warning: Remote connection disconnect. Retrying...
VAB: Warning: Remote connection disconnect. Retrying...
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.
here is the vagrant file without any modifications.
# -*- mode: ruby -*-
# vi: set ft=ruby :
require 'json'
require 'yaml'
VAGRANTFILE_API_VERSION ||= "2"
confDir = $confDir ||= File.expand_path("vendor/laravel/homestead", File.dirname(__FILE__))
homesteadYamlPath = File.expand_path("Homestead.yaml", File.dirname(__FILE__))
homesteadJsonPath = File.expand_path("Homestead.json", File.dirname(__FILE__))
afterScriptPath = "after.sh"
customizationScriptPath = "user-customizations.sh"
aliasesPath = "aliases"
require File.expand_path(confDir + '/scripts/homestead.rb')
Vagrant.require_version '>= 1.9.0'
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
if File.exist? aliasesPath then
config.vm.provision "file", source: aliasesPath, destination: "/tmp/bash_aliases"
config.vm.provision "shell" do |s|
s.inline = "awk '{ sub(\"\r$\", \"\"); print }' /tmp/bash_aliases > /home/vagrant/.bash_aliases"
end
end
if File.exist? homesteadYamlPath then
settings = YAML::load(File.read(homesteadYamlPath))
elsif File.exist? homesteadJsonPath then
settings = JSON::parse(File.read(homesteadJsonPath))
else
abort "Homestead settings file not found in " + File.dirname(__FILE__)
end
Homestead.configure(config, settings)
if File.exist? afterScriptPath then
config.vm.provision "shell", path: afterScriptPath, privileged: false, keep_color: true
end
if File.exist? customizationScriptPath then
config.vm.provision "shell", path: customizationScriptPath, privileged: false, keep_color: true
end
if defined? VagrantPlugins::HostsUpdater
config.hostsupdater.aliases = settings['sites'].map { |site| site['map'] }
end
end
Steps
vagrant destroy -f
deleted the old '.vagrant' directory
vagrant up
Best solution is not destroying the VM every time this error pops out (I did it for a while), since that will require a lot of time for the VM re-creation.
The straight forward solution is to just go into the oracle box and open the remote terminal and press S to skip the mounting since the box is hanging when booting up (do this just after you run vagrant up).

Virtualbox fails to connect due to Windows Firewall, Vagrant cannot start

I have an Ubuntu 14.04 Vagrant box that I am trying to use on a Windows 10 host.
The box is not the issue as it works fine on other systems.
My Virtualbox version is currently 5.1.28, I tried the latest version which is when the problem started so I rolled back to 5.1.28 hoping that would fix it, to no avail.
My Vagrant version is 2.0.0.
This is what I get when I run vagrant up
λ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'dev_box'...
==> default: Matching MAC address for NAT networking...
==> default: Setting the name of the VM: Dev_default_1512943736797_96012
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
default: Adapter 2: bridged
==> default: Forwarding ports...
default: 3000 (guest) => 3000 (host) (adapter 1)
default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> 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
default: Warning: Connection aborted. Retrying...
default: Warning: Connection reset. Retrying...
default: Warning: Connection aborted. Retrying...
default: Warning: Connection reset. Retrying...
default: Warning: Connection aborted. Retrying...
default: Warning: Connection aborted. Retrying...
default: Warning: Connection reset. Retrying...
default: Warning: Connection aborted. Retrying...
default: Warning: Connection reset. Retrying...
default: Warning: Connection aborted. Retrying...
default: Warning: Connection aborted. Retrying...
default: Warning: Connection reset. Retrying...
default: Warning: Connection aborted. Retrying...
default: Warning: Connection reset. Retrying...
default: Warning: Connection aborted. Retrying...
default: Warning: Connection reset. Retrying...
default: Warning: Connection aborted. Retrying...
default: Warning: Connection reset. Retrying...
default: Warning: Connection aborted. Retrying...
default: Warning: Connection reset. Retrying...
default: Warning: Connection aborted. Retrying...
default: Warning: Connection reset. Retrying...
default: Warning: Connection aborted. Retrying...
default: Warning: Connection aborted. Retrying...
default: Warning: Connection reset. Retrying...
default: Warning: Connection aborted. Retrying...
default: Warning: Connection reset. Retrying...
default: Warning: Connection aborted. Retrying...
default: Warning: Connection aborted. Retrying...
default: Warning: Connection reset. Retrying...
default: Warning: Connection aborted. Retrying...
default: Warning: Connection reset. Retrying...
default: Warning: Connection aborted. Retrying...
default: Warning: Connection reset. Retrying...
default: Warning: Connection aborted. Retrying...
default: Warning: Connection reset. Retrying...
default: Warning: Connection aborted. Retrying...
default: Warning: Connection reset. Retrying...
default: Warning: Connection aborted. Retrying...
default: Warning: Connection reset. Retrying...
default: Warning: Connection aborted. Retrying...
default: Warning: Connection reset. Retrying...
default: Warning: Connection aborted. Retrying...
default: Warning: Remote connection disconnect. Retrying...
default: Warning: Connection aborted. Retrying...
default: Warning: Connection reset. Retrying...
default: Warning: Connection aborted. Retrying...
default: Warning: Connection reset. Retrying...
default: Warning: Connection aborted. Retrying...
default: Warning: Connection reset. Retrying...
default: Warning: Connection aborted. Retrying...
default: Warning: Connection aborted. Retrying...
default: Warning: Connection reset. Retrying...
default: Warning: Connection aborted. Retrying...
default: Warning: Connection reset. Retrying...
default: Warning: Connection aborted. Retrying...
The guest machine entered an invalid state while waiting for it
to boot. Valid states are 'starting, running'. The machine is in the
'unknown' state. Please verify everything is configured
properly and try again.
If the provider you're using has a GUI that comes with it,
it is often helpful to open that and watch the machine, since the
GUI often has more helpful error messages than Vagrant can retrieve.
For example, if you're using VirtualBox, run `vagrant up` while the
VirtualBox GUI is open.
The primary issue for this error is that the provider you're using
is not properly configured. This is very rarely a Vagrant issue.
I thought this might be a Firewall issue, so I disabled the Firewall, but am still seeing the same issue.
How can I get Virtualbox/Vagrant to work on Windows 10?
EDIT: The issue was that Windows Firewall had closed ports that were previously open on my system before I updated to the Fall Creators Update, specifically in this case port 22. I created an exception to allow that port 22 through, now it works as expected.
Running Windows7 I ran into the same problem.
Try this recomendation on superuser.com
https://superuser.com/questions/936581/how-to-config-windows-firewall-so-vm-host-only-can-ping-windows-7
I think Virtualization is not enabled on your BIOS.
Check that in: task manager > Performance tab> Virtualization
or through systeminfo from CMD
If disabled:
Check out how to enable it from BIOS, based on your hardware make.
If enabled:
Then try disabling "Hyper-V" from "Add or remove windows features"
You can also try to launch a 64 bit vm manually from Virtualbox, this may tell you the reason behind machine being in "unknown state"
Also, try creating a Vagrant File with following config (with 32 bit OS):
Vagrant.configure(2) do |config|
config.vm.box = "hashicorp/precise32"
config.vm.box_download_insecure = true #true just to bypass ssl validation error (strict no for production)
end
Try running vagrant up from same directory.

Solution for vagrant installation

i need your help because i have to use cakebox for a project but i have some problems when i type vagrant up i get this error. I tried everything but it did not work.
Thanks in advance !
My-PC MINGW64 /A/App_LeagueUp!/cakebox (dev)
$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'cakebox'...
==> default: Matching MAC address for NAT networking...
==> default: Setting the name of the VM: cakebox_default_1444639086577_31058
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
default: Adapter 2: hostonly
==> default: Forwarding ports...
default: 22 => 2222 (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> 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
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
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.
My recomendation to figure out the problem is to set the
vb.gui flag to true in your Vagrantfile . add run then vagrant up. this will open the console, on a different window. It sometimes happen to me and then i reboot and everything is working fine.
If it doesnt post findings here, at least youll have more info
Try to enable virtualization from your boot menu and try it again.

Vagrant: undo all changes made by setting static private ip

Vagrant was running great for me and now vagrant up takes forever to boot up:
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
default: Warning: Remote connection disconnect. Retrying...
default: Warning: Remote connection disconnect. Retrying...
default: Warning: Remote connection disconnect. Retrying...
default: Warning: Remote connection disconnect. Retrying...
default: Warning: Remote connection disconnect. Retrying...
After about 30 of these messages and a few minutes later it finally goes through.
The only thing I changed was I set a private static ip address:
config.vm.network "private_network", ip: "192.168.33.10" in the Vagrant file.
I have since commented this line out of the vagrant file. How can I undo all changes that were made when I changed this setting? I have deleted the files in /var/lib/dhcp/ but this didn't seem to help.

Resources