Vagrant Warning: Connection refused. Retrying

旧城冷巷雨未停 提交于 2021-02-07 11:37:12

问题


Testing default example

$ vagrant init hashicorp/precise32
$ vagrant up

My box:

  • Windows 8.1
  • VirtualBox 5.0.2
  • Vagrant 1.7.4
  • Intel i7-4700MQ CPU witch seems to have Intel® Virtualization Technology (VT-x) http://ark.intel.com/products/75117/Intel-Core-i7-4700MQ-Processor-6M-Cache-up-to-3_40-GHz

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

While VM shows:

And I can log in successfully:

Firewall / Antivirus turned off.

Hyper-V is not installed

I have tried connecting via putty to 127.0.0.1 2222

EDIT:

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.


回答1:


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.




回答2:


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




回答3:


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"
    confg.ssh.password = "vagrant"
end

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




回答4:


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!



来源:https://stackoverflow.com/questions/32373249/vagrant-warning-connection-refused-retrying

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!