Vagrant up and reload - default: Warning: Connection timeout. Retrying...

14,971

Solution 1

After struggling with all the various options available on different questions, I was still facing the same problem. Finally, I did a

vagrant destroy

followed by

vagrant up

And I have my system working again.

Note: If you too have the habit to directly switch off your computer, you might face this problem soon! In your vagrant terminal (vagrant ssh), always go for a:

sudo shutdown -h now

or you can just type

vagrant halt

after you logout from your ssh.

PS: For those of you who might be afraid to lose your data/code/anything during vagrant destroy, you might relax! I was hesitant using the command, but as per the documentation, all it does is:

This command stops the running machine Vagrant is managing and destroys all resources that were created during the machine creation process. After running this command, your computer should be left at a clean state, as if you never created the guest machine in the first place.

This implies that your code will remain intact, and the next vagrant up would lead you to the same state as you left, only with the problem solved now. :)

Solution 2

Instead of destroying the image. I was able to fix the issue by first adding the following lines/uncomment inside Vagrantfile to turn the virtualbox gui on.

config.vm.provider "virtualbox" do |vb|
 vb.gui = true
 vb.memory = "1024"
end

Then I did vagrant up to reboot it. It started both command line and virtualbox gui. Gui asked me for SSH passphrase (which I set up when I was playing with ssh last time I was logged into the machine) and I was able to login. Later I powered off the image. Later I removed above lines for gui from Vagrantfile and it was still booting fine.

Share:
14,971
ankita
Author by

ankita

Updated on July 24, 2022

Comments

  • ankita
    ankita almost 2 years

    I had a fully functional vagrant for three months now, but for the last three days, I am getting errors whenever I try to run vagrant up or vagrant reload.

    This is the error I get when running vagrant reload

    default: Attempting graceful shutdown of VM...
    default: Guest communication could not be established! This is usually because
    default: SSH is not running, the authentication information was changed,
    default: or some other networking issue. Vagrant will force halt, if
    default: capable.
    default: Forcing shutdown of VM...
    default: Clearing any previously set forwarded ports...
    default: Clearing any previously set network interfaces...
    default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
    default: Adapter 2: hostonly
    default: Forwarding ports...
    default: 80 => 8080 (adapter 1)
    default: 22 => 2222 (adapter 1)
    default: Running 'pre-boot' VM customizations...
    default: Booting VM...
    default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key
    default: Warning: Connection timeout. Retrying...
    default: Warning: Connection timeout. Retrying...
    default: Warning: Connection timeout. Retrying...
    default: Warning: Connection timeout. Retrying...
    default: Warning: Connection timeout. Retrying...
    default: Warning: Connection timeout. Retrying...
    default: Warning: Connection timeout. Retrying...
    default: Warning: Connection timeout. Retrying...
    default: Warning: Connection timeout. Retrying...
    default: Warning: Connection timeout. Retrying...
    default: Warning: Connection timeout. Retrying...
    default: Warning: Connection timeout. Retrying...
    default: Warning: Connection timeout. Retrying...
    default: Warning: Connection timeout. Retrying...
    default: Warning: Connection timeout. Retrying...
    default: Warning: Connection timeout. Retrying...
    default: Warning: Connection timeout. Retrying...
    default: Warning: Connection timeout. Retrying...
    default: Warning: Connection timeout. Retrying... 
    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.
    

    I am using Elementary OS Luna and updated the latest versions of vagrant as well as virtualbox as some answers suggested. But the problems persist.

    I have tried most of the popular solutions including enabling the GUI and this. I also tried the solution given here but could not since my virtual box doesn't login.

    However, the GUI presented me with this:

     keys: press S to skip mounting or M for manual recovery
    

    I tried both the keys one by one but the problem still remains.

    Has anyone had this before who could offer a solution, vagrant isn't widely covered on the web yet and I cant find a reason why this is occurring.