# Vagrant box not getting set up running under WSL2

**URL:** <https://forum.ansible.com/t/vagrant-box-not-getting-set-up-running-under-wsl2/33989>\
**Category:** Ansible Project\
**Tags:** windows, ubuntu\
**Created:** [October 8, 2020, 5:14pm UTC](https://forum.ansible.com/t/vagrant-box-not-getting-set-up-running-under-wsl2/33989 "2020-10-08T17:14:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Keith\_Mills](https://avatars.discourse-cdn.com/v4/letter/k/b77776/32.png) [@Keith\_Mills](https://forum.ansible.com/u/Keith_Mills)\
**Post date:** [October 8, 2020, 5:14pm UTC](https://forum.ansible.com/t/vagrant-box-not-getting-set-up-running-under-wsl2/33989/1 "2020-10-08T17:14:38Z")

</div>

Vagrant version:

Vagrant 2.2.10

Host OS:

Windows 10 (20045, May 2020)

Guest OS:

Ubuntu 18.04 (tried with 16.04, 20.04)

Vagrantfile:

Vagrant.configure(“2”) do |config|  
config.vm.box = “ubuntu/trusty64”

config.vm.synced\_folder “.”, “/vagrant”, disabled: true

config.vm.provider “virtualbox” do |vb|  
vb.memory = “4024”  
vb.cpus = “1”  
end

config.vm.provision “ansible” do |ansible|  
ansible.become = true  
ansible.verbose = “v”  
ansible.playbook = “roles/firewall.yml”  
ansible.galaxy\_roles\_path = “./roles”  
end  
end

Error:

/mnt/c/Users/KeithJames/firewall-role-ak$ vagrant up --provisionBringing machine ‘default’ up with ‘virtualbox’ provider… ==\> default: Checking if box ‘ubuntu/trusty64’ version ‘20190514.0.0’ is up to date… ==\> default: Running provisioner: ansible… default: Running ansible-playbook… PYTHONUNBUFFERED=1 ANSIBLE\_FORCE\_COLOR=true ANSIBLE\_ROLES\_PATH=‘/mnt/c/Users/KeithJames/firewall-role-ak/roles’ ANSIBLE\_HOST\_KEY\_CHECKING=false ANSIBLE\_SSH\_ARGS=‘-o UserKnownHostsFile=/dev/null -o IdentitiesOnly=yes -o ControlMaster=auto -o ControlPersist=60s’ ansible-playbook --connection=ssh --timeout=30 --limit=“default” --inventory-file=/mnt/c/Users/KeithJames/firewall-role-ak/.vagrant/provisioners/ansible/inventory --become -v roles/firewall.yml Using /etc/ansible/ansible.cfg as config file PLAY [all] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* TASK [Gathering Facts] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* fatal: [default]: UNREACHABLE! =\> {“changed”: false, “msg”: “Failed to connect to the host via ssh: ssh: connect to host 127.0.0.1 port 2222: Connection refused”, “unreachable”: true} PLAY RECAP \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* default : ok=0 changed=0 unreachable=1 failed=0 skipped=0 rescued=0 ignored=0 Ansible failed to complete successfully. Any error output should be visible above. Please fix these errors and try again.

Expected behavior:

The VirtualBox VM should be started, Vagrant should be able to connect to it (instead I get

default: Warning: Connection refused. Retrying…

over and over, and I can’t connect via SSH).

Actual behavior:

Vagrant inside WSL2 can’t connect to the VM it just started.

/mnt/c/Users/KeithJames/firewall-role-ak$ service ssh status\* sshd is running

Steps to reproduce:

1. Install WSL2 on Windows 10 (2004), with Ubuntu bash

2. Create a directory with the above Vagrantfile in it

3. Download and install Vagrant for Linux in the WSL2 environment (regardless of it being installed in Windows)

4. Run vagrant up

I also tried:

Run vagrant ssh in WSL2.

/mnt/c/Users/KeithJames/firewall-role-ak$ vagrant ssh  
/mnt/c/Users/KeithJames/firewall-role-ak$

Then I tried using raw SSH:

/mnt/c/Users/KeithJames/firewall-role-ak$ ssh -p 2222 [vagrant@127.0.0.1](mailto:vagrant@127.0.0.1)  
ssh: connect to host 127.0.0.1 port 2222: Connection refused

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [October 8, 2020, 6:45pm UTC](https://forum.ansible.com/t/vagrant-box-not-getting-set-up-running-under-wsl2/33989/2 "2020-10-08T18:45:29Z")

</div>

So this is a connectivity issue with your vagrant VM.  
If you fix that the ansible playbook that vagrant calls will also start to work.

---

<div class="post-metadata">

**Author:** ![Keith\_Mills](https://avatars.discourse-cdn.com/v4/letter/k/b77776/32.png) [@Keith\_Mills](https://forum.ansible.com/u/Keith_Mills)\
**Post date:** [October 8, 2020, 9:32pm UTC](https://forum.ansible.com/t/vagrant-box-not-getting-set-up-running-under-wsl2/33989/3 "2020-10-08T21:32:32Z")

</div>

Thanks Dick
