Take the 2-minute tour ×

vagrant up fails when it gets to the ssh part:

myterminal$ vagrant up
[default] VM already created. Booting if its not already running...
[default] Running any VM customizations...
[default] Clearing any previously set forwarded ports...
[default] Forwarding ports...
[default] -- ssh: 22 => 2222 (adapter 1)
[default] -- db2: 30003 => 30003 (adapter 1)
[default] Cleaning previously set shared folders...
[default] Creating shared folders metadata...
[default] Booting VM...
[default] Failed to connect to VM!
Failed to connect to VM via SSH. Please verify the VM successfully booted
by looking at the VirtualBox GUI.

Then when I subsequently try and connect using vagrant ssh or vagrant reload or similar, I get this:

myterminal$ vagrant reload
[default] Attempting graceful shutdown of linux...
SSH connection was refused! This usually happens if the VM failed to
boot properly. Some steps to try to fix this: First, try reloading your
VM with `vagrant reload`, since a simple restart sometimes fixes things.
If that doesn't work, destroy your VM and recreate it with a `vagrant destroy`
followed by a `vagrant up`. If that doesn't work, contact a Vagrant
maintainer (support channels listed on the website) for more assistance.

Please help! I'm really stumped.

Kind regards,


share|improve this question

migrated from stackoverflow.com Oct 3 '11 at 12:10

This question came from our site for professional and enthusiast programmers.

16 Answers 16

up vote 6 down vote accepted

I saw this problem with my setup and eventually narrowed it down to the fact that I'd added a name onto the local hosts file. So I had: localhost myname myalias

Removed the myalias which I'd added and it booted okay. Thanks to @saphirlazuli for the clue that it was networking related.

share|improve this answer

I have had the same problem with the box given in the "Getting started" of Vagrant site. My solution below is for this tutorial's box.

I find a solution here : https://github.com/mitchellh/vagrant/issues/391

  1. in the VagrantFile, add the gui mode : config.vm.boot_mode = :gui
  2. run vagrant up
  3. in the gui, log with the user "vagrant" (password = "vagrant")
  4. int the gui, run sudo /etc/init.d/networking restart, in /etc/network/interfaces file, you must now have a section with #VAGRANT-BEGIN [...]#VAGRANT-END
  5. run vagrant reload on the physical machine
share|improve this answer
This worked for me, thanks. I had Vagrant running before, then it stopped working with a new box. Any idea what causes it? –  Andrew Vit Jul 2 '11 at 4:57
I did restart, but in /etc/network/interfaces I don't have section with #VAGRANT-BEGIN [...]#VAGRANT-END, any clue why? Can I add it manually? –  sparrovv Oct 7 '11 at 8:02

This is an intermittent problem for me, and definitely seems to be related to networking. I found some more helpful information at Vagrant GitHub issues #391 and #455. I tried deleting my unused host-only network in VirtualBox settings (as recommended as a potential fix in one of the GitHub issues) which didn't seem to help.

Starting in gui mode (as described in a previous answer) is a great way to debug/fix problems. I found that it's because for whatever reason, the VM cannot obtain an IP address on startup. Starting in GUI mode then logging in (vagrant/vagrant) and running sudo dhclient in the guest OS would retrieve the IP address and the Vagrant setup process would complete successfully.

Still looking for a permanent fix though.

Hope this helps!

[EDITED TO ADD]: A helpful suggestion was added to GitHub Issue #455 which involves adding the following config to your Vagrantfile:

config.ssh.max_tries = 150

This is currently working for me, and seems to make sense since the problem seems to be related to timeout - increasing the number of tries should increase the probability of the SSH process succeeding in time. It's an intermittent issue in the first place so I'll reserve judgement for a while, but fingers crossed it'll work! Thanks to karel1980 for suggesting the fix.

share|improve this answer

If vagrant up fails, I recommend the following:

  1. Boot with gui mode: this helps to see if the image is broken (or e.g. what it does before the provisioning is started), set config.vm.boot_mode = :gui in your Vagrantfile
  2. Debug logging: run the provisioning with debug, chef.log_level = :debug
  3. Repackage the box: sometimes you need to install something before everything else runs - to bootstrap the bootstrapper. That's not really possible, so the easiest is to boot a vm without any provisioning, install whatever you need and re-package the box (vagrant box repackage foo, then vagrant import foo and then add foo in your Vagrantfile)

Note: gui mode can have other issues, e.g. for me no provisioning works with vagrant 0.7.5 when gui is enabled. It's still great to debug the actual box though.

share|improve this answer

If the kernel module is already installed, try starting the VM directly with VirtualBox. This will show you any startup errors encountered as the VM boots. Problems like filesystem errors will stop the SSH server daemon from operating correctly.

share|improve this answer

I had the same problem on osx (VirtualBox 4.1.0 and Vagrant 0.8.6), and for me the only help was to:

  1. login with :gui by login/pass: vagrant/vagrant
  2. modify the “/etc/rc.local” file to include the line “sh /etc/init.d/networking restart” just before “exit 0″.
  3. disable :gui
  4. vagrant reload

I've found this at: https://github.com/mitchellh/vagrant/issues/391 thx mikhailov.

share|improve this answer

I had this same problem. In my case 64-bit emulation wasn't enabled. Enabling this feature in my bios fixed the issue.

share|improve this answer

My network card type was originally set to 82540EM. I changed it to Am79C973 and now Vagrant up works every time. I've started multiple VMs, even rebooted the host and it still works.

The command is:

VBoxManage modifyvm yourmachinename --nictype1 Am79C973

Remember to repackage and readd your box to Vagrant.

I'm running Debian Squeeze 64-bit as host and guests, using VirtualBox 4.1.16 on a Core i7-2600 machine.

share|improve this answer

My guest box would not boot properly due to a disk issue.

I forced the VM to close via

VBoxManage controlvm poweroff

Then I modified my Vagrantfile to include this line:

config.vm.boot_mode = :gui

Next, I re-ran

vagrant up

In the GUI that popped up, I had to run the 'disk fixer' utility.

After running the disk utility, my VM was successfully booted, and then I could run vagrant ssh.

share|improve this answer

I uncommented the part in the Vagrantfile like this:

  config.vm.provider :virtualbox do |vb|
    # Don't boot with headless mode
    vb.gui = true

    # Use VBoxManage to customize the VM. For example to change memory:

I saved it and then I did

vagrant reload

and then things worked fine. I'm not sure why that fixed it though.

share|improve this answer

Type sudo /etc/init.d/vboxdrv setup . It should now work.

share|improve this answer

My problem was that in


I had entry lucid32

where as my box name was lucidtest, I changed the above line to lucidtest

and it worked.

share|improve this answer

This message suggests ssh server is not running on the VM. make sure it is installed

sudo apt-get install openssh-server

and running

ssh localhost

should not give an error.

To exclude errors within vagrant, you should try ssh into the vm directly by:

ssh vagrant@localhost -p2222

(assuming default user and port forwarding )

share|improve this answer

On windows 7 run

vagrant ssh

if you get something like this...

PuTTY). The authentication information is shown below:

Port: 2222
Username: vagrant
Private key: U:/.vagrant.d/insecure_private_key

Then you should use something like this...

ssh vagrant@ -p 2222 -i /cygdrive/u/.vagrant.d/insecure_private_key

Notice I am using cygwin on my windows box rather than Putty.

share|improve this answer

I shut down the running vm and created a new basebox:

  1. Shut down vm I am trying to export
  2. $ vagrant package --base "salt-master basebox" --vagrantfile ./Vagrantfile
share|improve this answer

Here is another possible reason for the error:

[default] Failed to connect to VM!
by looking at the VirtualBox GUI.

A username can be specified in the config file like this:

config.ssh.username = "badusername"

If that username does not exist or cannot be logged into for some reason, neither you nor Vagrant will be able to SSH into the VM. Thus Vagrant will "fail to connect", even if the VM is in fact running and working properly.

share|improve this answer

Your Answer

