vagrant icon indicating copy to clipboard operation
vagrant copied to clipboard

"Warning: Connection refused. Retrying" is repeat and not connect VM

Open bosungs opened this issue 4 years ago • 17 comments

Vagrant version

2.2.14

Host operating system

windows 10 pro ans WSL2

Guest operating system

ubuntu/trusty64

Vagrantfile

I get vagrant init ubuntu trusty64 and not modify

Debug output

Provide a link to a GitHub Gist containing the complete debug output: https://www.vagrantup.com/docs/other/debugging.html. The debug output should be very long. Do NOT paste the debug output in the issue, just paste the link to the Gist. image

Expected behavior

vagrant up

Actual behavior

"Warning: Connection refused. Retrying" is repeat unlimtly and not connect VM

Steps to reproduce

Environment: Windows 10 Pro / WSL2(Ubuntu) / Virtualbox

  1. vagrant init ubuntu/trusty64
  2. vagrant up

References

I compare to vagrant tasks on Ubuntu host. Ubuntu host's Virtualbox VM is 2 Network Adapter(NAT, host-only) but Windows host's Virtualbox VM is 1 Network Adaptaer(only NAT) I think bug is correlate Network adapter.

bosungs avatar Nov 26 '20 07:11 bosungs

hi @bosungkim-git can you add the exact build of your Windows 10 pro? thank you

jason-migz avatar Dec 03 '20 06:12 jason-migz

@all @soapy1 i think WSL 2 and vagrant will not work when hyper-v is turn on, instead use WSL 1. i tested it and it works.

jason-migz avatar Dec 06 '20 05:12 jason-migz

I'm experiencing the same problem, though I swear that it worked flawlessly with WSL2 up until some months ago.

Loads of questions have been asked on Stack Overflow regarding this exact topic over the last month, so it's definitely a problem.

Now it seems like that the only reliable way to get Vagrant and Ansible working together is running a Linux OS. And here I (stupidly) thought that Windows and WSL2 could accommodate all my needs...

ImMaury avatar Dec 07 '20 21:12 ImMaury

I'm experiencing the same problem, though I swear that it worked flawlessly with WSL2 up until some months ago.

Loads of questions have been asked on Stack Overflow regarding this exact topic over the last month, so it's definitely a problem.

Now it seems like that the only reliable way to get Vagrant and Ansible working together is running a Linux OS. And here I (stupidly) thought that Windows and WSL2 could accomodate all my needs...

@ImMaury if cannot turn off hyper-v in windows 10, just use it as a vagrant provider, i am already using it.

if you turn of your hyper-v, you can use vagrant and virtualbox on WSL 1. it is working as expected.

jason-migz avatar Dec 08 '20 03:12 jason-migz

I'm experiencing the same problem, though I swear that it worked flawlessly with WSL2 up until some months ago. Loads of questions have been asked on Stack Overflow regarding this exact topic over the last month, so it's definitely a problem. Now it seems like that the only reliable way to get Vagrant and Ansible working together is running a Linux OS. And here I (stupidly) thought that Windows and WSL2 could accomodate all my needs...

@ImMaury if cannot turn off hyper-v in windows 10, just use it as a vagrant provider, i am already using it.

if you turn of your hyper-v, you can use vagrant and virtualbox on WSL 1. it is working as expected.

There are too many caveats for me when it comes to using Hyper-V.

And no, I cannot turn off Hyper-V/WSL2 because I need Docker.

Welp, having Vagrant working on Windows with all the whistles and bells was a dream that didn't last long.

ImMaury avatar Dec 08 '20 20:12 ImMaury

@ImMaury i created a Video Tutorial guide for Vagrant and hyper-V, please check it Vagrant using Hyper-V (Substitute for Virtualbox problem in Windows 10 Pro) thank you

jason-migz avatar Dec 09 '20 12:12 jason-migz

I've just figured out that Vagrant works fine with Virtualbox on WSL1 WITHOUT having to disable Hyper-V. It's probably a networking problem caused by WSL2 that prevents Vagrant from talking with the Virtualbox VMs (not sure if this is relevant: https://github.com/microsoft/WSL/issues/4150#issuecomment-504209723).

So for the time being I'll be using a WSL1 distro just for Vagrant.

ImMaury avatar Dec 09 '20 22:12 ImMaury

I've just figured out that Vagrant works fine with Virtualbox on WSL1 WITHOUT having to disable Hyper-V. It's probably a networking problem caused by WSL2 that prevents Vagrant from talking with the Virtualbox VMs (not sure if this is relevant: microsoft/WSL#4150 (comment)).

So for the time being I'll be using a WSL1 distro just for Vagrant.

@ImMaury yes better use WSL1 for the meantime. the main problem is WSL 2 needs hyper-v to turn on but virtualbox needs hyper-v to turn off.

jason-migz avatar Dec 10 '20 08:12 jason-migz

I've just figured out that Vagrant works fine with Virtualbox on WSL1 WITHOUT having to disable Hyper-V. It's probably a networking problem caused by WSL2 that prevents Vagrant from talking with the Virtualbox VMs (not sure if this is relevant: microsoft/WSL#4150 (comment)). So for the time being I'll be using a WSL1 distro just for Vagrant.

@ImMaury yes better use WSL1 for the meantime. the main problem is WSL 2 needs hyper-v to turn on but virtualbox needs hyper-v to turn off.

@jason-migz that's not true, latest versions of VirtualBox do work even when Hyper-V is enabled.

ImMaury avatar Dec 10 '20 15:12 ImMaury

I've just figured out that Vagrant works fine with Virtualbox on WSL1 WITHOUT having to disable Hyper-V. It's probably a networking problem caused by WSL2 that prevents Vagrant from talking with the Virtualbox VMs (not sure if this is relevant: microsoft/WSL#4150 (comment)). So for the time being I'll be using a WSL1 distro just for Vagrant.

@ImMaury yes better use WSL1 for the meantime. the main problem is WSL 2 needs hyper-v to turn on but virtualbox needs hyper-v to turn off.

@jason-migz that's not true, latest versions of VirtualBox do work even when Hyper-V is enabled.

@ImMaury did you already try it in windows 10 pro build 19042.685? i tried it and it's not working, that is why i made this tutorial video for Vagrant using hyper-v

jason-migz avatar Dec 11 '20 05:12 jason-migz

I've just figured out that Vagrant works fine with Virtualbox on WSL1 WITHOUT having to disable Hyper-V. It's probably a networking problem caused by WSL2 that prevents Vagrant from talking with the Virtualbox VMs (not sure if this is relevant: microsoft/WSL#4150 (comment)). So for the time being I'll be using a WSL1 distro just for Vagrant.

@ImMaury yes better use WSL1 for the meantime. the main problem is WSL 2 needs hyper-v to turn on but virtualbox needs hyper-v to turn off.

@jason-migz that's not true, latest versions of VirtualBox do work even when Hyper-V is enabled.

@ImMaury did you already try it in windows 10 pro build 19042.685? i tried it and it's not working, that is why i made this tutorial video for Vagrant using hyper-v

@jason-migz no, my build number is 19041.685 (Windows 10 Pro). I'm not in the insider program.

Edit: I've updated to 20H2 (build number: 19042.685) and VirtualBox is still working. My VirtualBox version is 6.1.16.

ImMaury avatar Dec 11 '20 21:12 ImMaury

The issue at hand is not Virtualbox / Hyper-V but the networking stack of WSL2

In WSL2 networking is done over an extra adapter (Hyper-V Virtual Ethernet Adapter) In my case this adapter is running a 172.17.80.1/20 network, where 172.17.80.1 is the windows host and my Debian WSL2 guest has 172.17.94.74

Now paired with the way the Virtualbox provider is implemented vagrant tries to connect SSH over 127.0.0.1 in the WSL2 "vm".but the virtualbox port forward 2222 -> 22 is only available locally on the windows side of the network.

For this to work three steps are required:

  1. any firewall on the windows side has to allow traffic in for port 2222 on the WSL2 adapter
  2. the port forward in Virtualbox needs to be configured to allow access from the WSL2 network (it is bound to 127.0.0.1 only)
  3. vagrant need to connect to 172.17.80.1 instead of localhost

merlin1991 avatar Feb 22 '21 13:02 merlin1991

A plugin for vagrant to use it in wsl2 exists. Hope this helps.

marian-lingsch avatar Mar 22 '21 19:03 marian-lingsch

After spending several hours trying to troubleshoot this issue when running vagrant up with WSL2, I ended up switching back to WSL1 and it finally worked.

I was following this tutorial which seemed to work for that user who was using WSL2, but not for me. After reinstalling my Ubuntu distro (20.04 LTS) following the same tutorial except with WSL1 this time vagrant started up with no issues.

@merlin1991 were you able to get vagrant working on WSL2? If so, do you mind sharing some more details on where those 3 configurations are made?

dattphan15 avatar May 16 '21 20:05 dattphan15

A plugin for vagrant to use it in wsl2 exists. Hope this helps.

@marian-lingsch this worked for me, thank you! Do you know if there's an equivalent for VMware Workstation/Desktop?

graememeyer avatar Jul 12 '21 20:07 graememeyer

@graememeyer Sorry I don't know if something similar exists for VMware.

marian-lingsch avatar Jul 13 '21 17:07 marian-lingsch

A plugin for vagrant to use it in wsl2 exists. Hope this helps.

@marian-lingsch, thanks for this solution!

This solved my issue! After hours of searching for a solution to my connection issue, I finally found one.

limfjm avatar Feb 14 '24 20:02 limfjm