13

Testing default example

$ vagrant init hashicorp/precise32
$ vagrant up

My box:

I know this is common error but after trying everything I still cannot make it work Getting error

While VM shows: enter image description here

And I can log in successfully: enter image description here

Firewall / Antivirus turned off.

Hyper-V is not installed
enter image description here

I have tried connecting via putty to 127.0.0.1 2222 enter image description here

EDIT: enter image description here

enter image description here

Vagrantfile (I have removed commented out lines)

Vagrant.configure(2) do |config|
    config.vm.box = "hashicorp/precise32"
end

This is what vagrant ssh does... nothing. And vagrant reload stuck on same issue. enter image description here

Ben
  • 175
  • 1
  • 2
  • 12
  • That's odd, because it should probably work out of the box, but try running `sudo netstat -ptaun` in the virtual machine and see if it has an sshd daemon listening on port 22. You can also try logging in with `vagrant ssh`, or `vagrant ssh -p -- -l vagrant`, using password 'vagrant'. EDIT: The connection is being refused, so you can ignore the second part of my comment, at least for now. – Paulo Almeida Sep 03 '15 at 10:52
  • can you show your Vagrantfile ? did you change something, why is it trying to ssh on your localhost. can you run `vagrant ssh-config` and put the result – Frederic Henri Sep 03 '15 at 10:53
  • I have edited my question to answer your questions. – Ben Sep 03 '15 at 15:37
  • @Ben I have edited my answer for the connection refused error, first I thought it was connection timeout – Frederic Henri Sep 12 '15 at 07:20
  • @Ben were you able to resolve this issue? If so, how? – aayoubi Feb 12 '16 at 16:03
  • The situation could be because of VirtualBox failed to redirect ports, despite saying '**==> default: Forwarding ports... default: 22 => 2222 (adapter 1)**' You may have a look at full description in my question here [link](http://stackoverflow.com/questions/36529651/virtualbox-nat-failed-to-redirect-tcp-127-0-0-12222-10-0-2-1522). I still have no idea how to fix redirection fail( Please drop a note in my post, if and how you succeed! – WebComer Apr 13 '16 at 18:25
  • @WebComer - Sadly, your link now fails. – Jesse Chisholm May 10 '17 at 20:18
  • @ Jesse Chisholm - unfortunately, some people closed my topic as off-topic as "too general" by Filburt, IInspectable, PetSerAl, Andrew Medico, Pang Apr 11 '16 at 1:32. i'm still sure - the problem exists and persists, and really deserves a good clear understandable solution. My question was - What could make NAT redirection fail and how to troubleshoot it? I guessed whether the problem is somewhere in Windows TCP stack or with VirtualBox or with some DCOM setting? – WebComer May 26 '17 at 22:27

4 Answers4

4

This happens with Vagrant from time to time with the first spin up. After it does that it will timeout and drop you back at the prompt, go vagrant ssh, it will let you in. If it does not go vagrant reload and it will restart the vm. This occurs because the vagrant images have dns turned off so it takes a while to resolve the connection. Again, this sometimes occurs on the first up after you download it and spin it up.

GHETTO.CHiLD
  • 3,267
  • 1
  • 22
  • 34
  • 1
    vagrant ssh does nothing. vagrant reload has same issue as vagrant up. Please see my question Edit – Ben Sep 03 '15 at 15:37
  • vagrant reload helped for me. It seems that the issue was that on the first vagrant up there were too old guest-additions. By running vagrant reload it was able to update the guest-additions and it started to work. – PHZ.fi-Pharazon Jan 14 '23 at 10:21
1

I suspect this could be a misconfigured VBox guest.

I suppose you could try making sure that NAT and port forwarding are enabled in the settings of your VM, and if they aren't, you could enable it manually: in the VirtualBox Graphical Manager, select the machine, click on settings, click on network at the right of the popup, check all the adapters and make sure that the adapter that is "attached to NAT" is enabled. Also, check the port forwarding settings. You can also access the network settings when you are running the VM, from the buttons at the bottom/left (the third button in your second pic, from left to right).

secenv
  • 191
  • 1
  • 6
0

here are a few things I would try (and I do understand you might have tried a lot of this and it might not solve your issues but just in case) :

  • follow the steps from https://www.hanselman.com/blog/SwitchEasilyBetweenVirtualBoxAndHyperVWithABCDEditBootEntryInWindows81.aspx to completely disable Hyper-V (not sure its enough from windows features - and even though you're using a 32-bit box)

  • not sure if you enabled the gui mode when you logged into the vm from virtual box or you just opened it after, but enable the option and check if nothing is blocking during the startup

     config.vm.provider :virtualbox do |vb|
       vb.gui = true
     end
    
  • use another ssh port (even though it does not mention there is a collision) you can try another port

     config.vm.network :forwarded_port, guest: 22, host: 2522, auto_correct: false, id: "ssh"
    

see after vagrant up if you can connect with putty.

  • optionally, you can run vagrant up --debug to get more information about the error, you will see where it loops/error and give the output of that for others on SO to comment

EDIT

Giving another look, I thought the issue was about connection timeout but it is connection refused the message says

SSH username: vagrant
SSH auth method: password

but you're not passing any password in the Vagrantfile you show. Just add

Vagrant.configure(2) do |config|
    config.vm.box = "hashicorp/precise32"
    config.ssh.username = "vagrant"
    config.ssh.password = "vagrant"
end

I would recommend to use ssh-key as it is a bit more simple to use.

errakeshpd
  • 2,544
  • 2
  • 28
  • 35
Frederic Henri
  • 51,761
  • 10
  • 113
  • 139
  • It's not a password issue if the connection's refused -- that'd indicate the host is refusing connections to that port at the TCP level before ssh can even come into play. – Christian Ternus Sep 12 '15 at 09:31
  • @ChristianTernus you're right but its strange that the Vagrantfile from the OP has not password and is kinda default and there's one screenshot showing authentication method and the 2nd one with private key, I've been confused – Frederic Henri Sep 12 '15 at 18:59
0

Something that I found out was the case for me after multiple destroys/reebots: check if you have an SSH agent running with a key loaded (like Pageant for PuTTY).

In my case having another SSH key loaded with Pageant (instead of the one configured for Vagrant) was conflicting with the authentication process, which resulted in endless "Connection refused. Retrying" and ultimately in me being unable to use Vagrant.

The solution is to either

  • Load the appropriate key in Pageant
  • Close pageant (what I usually do, as it's faster in my case)

Hope this helps someone out there!

Christian Fratta
  • 294
  • 3
  • 10