Ben
Ben

Reputation: 175

Vagrant Warning: Connection refused. Retrying

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

Upvotes: 13

Views: 20987

Answers (5)

Vikas Piprade
Vikas Piprade

Reputation: 352

Installing virtualbox_WSL2 plugin in WSL using below command resolved my issue

vagrant plugin install virtualbox_WSL2

enter image description here

Upvotes: 0

Frederic Henri
Frederic Henri

Reputation: 53713

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.

Upvotes: 0

Christian Fratta
Christian Fratta

Reputation: 294

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!

Upvotes: 0

secenv
secenv

Reputation: 191

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).

Upvotes: 1

GHETTO.CHiLD
GHETTO.CHiLD

Reputation: 3416

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.

Upvotes: 4

Related Questions