Fixing Kali Linux on Windows WSL2

With Windows Subsystem for Linux (WSL), Microsoft offers a near native way to run Linux on Windows. Released three years ago in 2016, the first release of WSL offered a compatibility layer allowing Linux binaries to run on Windows. This compatibility layer however was limited in that the Linux software could not access hardware elements such as the network stack directly. Thus, popular packages such as nmap or wireshark would not run, rendering Linux distributions such as Kali (available from Microsoft Store) almost useless.

Microsoft is currently testing WSL2 where the Linux kernel runs in a virtual machine, allowing for greater compatibility and access to virtual hardware resources. Members of the Windows Insider program can test these features as well. Unfortunately, due to a bug in the latest releases (e.g. build 18956, 18963, 18965) many distributions such as Kali Linux won’t run in WSL2 after being installed from the Microsoft Store or after being converted from WSL1 to WSL2. Preexisting installations cannot be launched and new installations keep issuing the following error message after asking the user to configure a new user name:

"A connection attempt failed because the connected party did not properly 
respond after a period of time, or established connection failed 
because connected host has failed to respond."

Until this issue is fixed however, there is a workaround enabling users to convert and run Kali or other distros in WSL2.

Use the following guide to install a working WSL2 version of Kali Linux enabling the use of nmap and other tools which require access to hardware features.

Step by step instruction

After installing the Windows Subsystem for Linux feature in Windows and before downloading any Linux distributions from the Microsoft Store make sure it is set to WSL1. Although this is the default setting, it doesn’t hurt to be on the safe side. Open a terminal (have you tried the new Microsoft Terminal?) and type in the following command:

wsl --set-default-version 1

Afterwards, install a Linux distro from the store.

If you have already installed Kali or another Linux distribution in WSL2 and realized it doesn’t run, you can convert it back to WSL1.

wsl --set-version kali-linux 1

Enter the installed Kali as root and check if the bin as well as the sbin folders are symlinks. If they are, delete the symlinks.

wsl -d kali-linux -u root

cd /
ls -Alh
rm bin
rm sbin

Get out of Linux and convert your installation to WSL2

wsl --set-version kali-linux 2

Enter the distro again as root and apply a workaround to your file system:

wsl -d kali-linux -u root -e /usr/bin/bash

cd /
mv bin/wslpath usr/bin/
mv sbin/mount.drvfs usr/sbin/
rmdir bin
rmdir sbin
mv usr/bin bin
mv usr/sbin sbin
ln -s /bin usr/bin
ln -s /sbin usr/sbin

To test it, leave the distro, terminate it, check the version info and enter it again

wsl -t kali-linux
wsl -l -v
wsl -d kali-linux

Now the distribution is ready and will allow nmap and other tools to run.

6 thoughts on “Fixing Kali Linux on Windows WSL2

  1. I think the command here:

    “Get out of Linux and convert your installation to WSL2

    wsl –set-version kali-linux 1”

    should be:

    wsl –set-version kali-linux 2


  2. Last command in the “work around” has a small (but important) typo!
    ln -s /sbin usr/sbi

    should be:
    ln -s /sbin usr/sbin

    Thank you so much for this article, worked perfect for me!


  3. Hi These steps should be

    mv usr/bin bin
    ln -s /bin usr/bin
    mv usr/sbin sbin
    ln -s /sbin usr/sbin

    Otherwise the second mv will faile


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s