Vagrant Warning: Connection refused. Retrying - vagrant

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.

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.

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

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!

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.

Related

Vagrant cannot vagrant up the box packaged from ubuntu xenial64 16.04

I have a custom vagrant box based on the offcial box ubuntu 16.04.
I simplly run like this to get the packaged box.
vagrant init ubuntu/xenial64; vagrant up --provider virtualbox
vagrant up
vagrant ssh # enter the virtual machine and do some custom change on it
vagrant halt
vagrant package --vagrantfile Vagrantfile --output custom_ubuntu1604.box
and then i copy the file custom_ubuntu1604.box to another directory, i use the box like this:
vagrant box add ubuntu1604base custom_ubuntu1604.box
vagrant init ubuntu1604base
vagrant up # at this point the machine will be stopped at "Started Journal Servie"
my new virtualbox machine base on the new packaged box will stop at:
the screenshot
And finally it timed out:
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.
Try to set config.vm.boot_timeout in Vagrantfile more than default e.x.600. From my experience I found out it take a long time at the first time to connecting guest machine.
For example
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/xenial64"
config.vm.provider "virtualbox"
config.vm.boot_timeout = 600
end

How can I configure private network in vagrant box

Setup:
On my laptop, I have windows 10 pro install. On that, I have installed latest virtualbox 5.1.2, latest vagrant 1.9.1 and latest packer 0.12.1. My laptop is highend and with strong configuration. I am on wifi.
Purpose:
I want to have three vagrant boxes running Windows 2012 r2 so that I can install SQL server on one, and two different web applications on others.
Success:
Till now I have managed to create vagrant boxes without any hassles. If I use forwarded port method, I am even able to rdp into those machines.
Failure:
My plan is to configure private network for these machines so that they can have their own ip addresses and can communicate with each other. But so far I am unable to achieve so. The private network settings as recommeded on vagrantup.com and other websites do not seem to work for me somehow, as I am sure I am doing some mistake somewhere.
can somebody please help me on how to go about this? I have searched a lot on this site also and gone through many suggestions but none seem to help.
Below is my vagrant file that I am using.
Vagrant.configure(2) do |config|
config.vm.box = "xxxx.box"
config.vm.communicator = "winrm"
config.vm.hostname = "xxxserver"
# Admin user name and password
config.winrm.username = "vagrant"
config.winrm.password = "vagrant"
config.vm.guest = :windows
config.windows.halt_timeout = 600
config.vm.network "private_network", ip: "192.168.50.4"
end
And below is the error message that I get when I run vagrant rdp
*
==> default: Detecting RDP info... RDP connection information for this machine could not be detected. This is typically caused when we can't
find the IP or port to connect to for RDP. Please verify you're
forwarding an RDP port and that your machine is accessible.
*
But if I replace
config.vm.network "private_network", ip: "192.168.50.4"
with
config.vm.network "forwarded_port" , host: 33390 , guest: 3389
and then reload the box then vagrant rdp works fine and I am able to loginto it. I want to use static ips for my vms.
Kindly guide..
thanks.
I also use a private_network with a static ip. Only adding (not replacing) the line config.vm.network "forwarded_port" , host: 33390 , guest: 3389 works.
$ vagrant rdp
==> fe: Detecting RDP info...
fe: Address: 127.0.0.1:33389`enter code here`
fe: Username: vagrant
==> fe: Vagrant will now launch your RDP client with the connection parameters
==> fe: above. If the connection fails, verify that the information above is
==> fe: correct. Additionally, make sure the RDP server is configured and
==> fe: running in the guest machine (it is disabled by default on Windows).
==> fe: Also, verify that the firewall is open to allow RDP connections.

Vagrant access guest machine from host (windows)

I installed a vagrant virtual machine in Windows, it's working fine, I am trying to connect to the guest machine from windows, but as soon as I uncomment some thing in Vagrantfile like :
config.vm.network "private_network", ip: "192.168.33.10"
OR
config.vm.network "public_network"
when reloading vagrant, I got this error :
The guest machine entered an invalid state while waiting for it
to boot. Valid states are 'starting, running'. The machine is in the
'poweroff' 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 know this does not make sense but I just open VirtualBox and with right-click goes to Settings of created vagrant machine image and diable Audio and it is working after save and run vagrant up
I never encountered that error personally, having never used vagrant on windows. This issue has been discussed here.

Laravel homestead stuck on VM login

Ill try to use laravel homestead vagrant box. When I do vagrant up it stucks on
default: Warning: Connection refused. Retrying...
My intel virtualization technology is enabled. I've enabled the GUI and it shows:
I've got Vagrant 1.6.5 and VirtualBox 4.3.16.
Anybody has encountered this problem as well...?
Default login and password is just vagrant.
A few things to try:
First, make sure your virtual machine is completely shut down, and relaunch Virtual Box.
Make sure "PAE/NX" is enabled, which you can do in the processor tab
of the Virtual Box GUI. A description of how to do that is
here.
When vagrant up gets stuck at Warning: Connection refused.
Retrying..., try entering vagrant as both the username and
password in the GUI and see if it will continue the loading process.
See related StackOverflow questions Vagrant stuck connection
timeout
retrying
and Vagrant up
timeout.
Also just in case check if the network adapter #1 is cable connected. That fixed the issue for me (ie: on VirtualBox > box settings > Network > Adapter 1 > Advanced > tick "Cable Connected). Or better, add this to your vagrant file:
config.vm.provider 'virtualbox' do |vb|
vb.customize ['modifyvm', :id, '--cableconnected1', 'on']
end
You can simply type vagrant ssh on the command line / terminal of the host machine (Assuming you've already fired up the machine with vagrant up). To quote the vagrantup.com website:
This command will drop you into a full-fledged SSH session

vagrant up hangs but vagrant ssh works

I'm working on os x 10.9.4, and the vagrant --version shows 1.3.3.
After waking up os x from sleep mode(in a different network environment), vagrant up hangs at Waiting for machine to boot. This may take a few minutes... then: Timed out while waiting for the machine to boot.
I tried to
config.vm.provider :virtualbox do |vb|
vb.gui = true
end
and the vm boots normally and I can login using username/password vagrant
Also, at this point, in another terminal, if I tryvagrant ssh, it will show vagrant#127.0.0.1's password: (I've never seen it asking password before) and I can login. The network of the vm seems to be fine and I can ping google.com within the vm.
Also, if I manually launch the vm directly from virtual box, I can also login via vagrant ssh(showing vagrant#127.0.0.1's password: again). The network is fine as well.
I've followed https://github.com/mitchellh/vagrant/wiki/%60vagrant-up%60-hangs-at-%22Waiting-for-VM-to-boot.-This-can-take-a-few-minutes%22 no luck, though. And I've also checked the ssh key. On the host, the insecure_private_key is -rw-------; and on vm, the authorized_keys shows -rw-r--r--
So, to sum up:
vagrant ssh works (asking for password)
I can ping within the vm
BUT vagrant up hangs
I'm totally lost. Why the vm works but vagrant up hangs?
As trivial it sounds, but for me un- and reinstalling was the only option left.
Debugging didn't bring up any errors... it seemed vagrant up was just dying.

Resources