Skip to content

Instantly share code, notes, and snippets.

@ryumada
Created December 24, 2023 02:57
Show Gist options
  • Save ryumada/b68141357d214af869650a68b092ce8f to your computer and use it in GitHub Desktop.
Save ryumada/b68141357d214af869650a68b092ce8f to your computer and use it in GitHub Desktop.
WSL no internet connection; WSL cannot bypass Windows Firewall; WSL internet access blocked by Windows Firewall Control (WFC)

The problem is when I enable this setting in my firewall.

image

I can't connect to internet from my WSL.

image

I have tried to allow connection to WSL using this guide microsoft/WSL#4585 (comment).

But still, the problem still persist. 😔

I assume that the port forwarding used by WSL interface is corrupted by Hyper-V that I just installed not so long ago. So, I disabled my Hyper-V via "Turn Windows Features On or Off" and then reboot my system.

Sadly, It still not working. I hope that Hyper-V could reset my WSL network Interface but it doesn't do it. It left the WSL network interface just the way it is.

So, I need the way to reconfigured my WSL network interface. I figured out that I should completely refresh install my WSL to readjust the network interface.

So, I follow this tutorial: 1

1. Backup any linux distributions you still want to use

wsl --export $DISTRIBUTION_NAME $PATH_TO_SAVE_FILE.tar 

2. Remove any WSL Update

From Apps & Features (a.k.a. Add or remove programs) in Windows, remove all of the Windows Subsystem for Linux Update. In my Windows there are 3 updates, so I remove them all.

3. Remove WSL from Windows Features

From Turn Windows Features on or off, disable this feature to remove completely WSL:

  • Windows Subsystem for Linux
  • Virtual Machine Platform

Then, reboot your Windows.

4. Enable again those 2 features to reinstall WSL

After reboot, reenable those 2 features again. This will perform a clean install of WSL freshly to your Windows just like out of the box.

5. Done ✅

The networking in WSL should work normally again.

In summary

Beware of Hyper-V, you should choose one whether you want to use WSL and WSA or in the other hand Hyper-V. I prefer to use WSL and WSA instead of Hyper-V. So, I remove Hyper-V feature from my Windows.


Footnotes

  1. NotTheDr01ds, “Answer to ‘Completely reinstall WSL,’” Super User. Accessed: Dec. 24, 2023. [Online]. Available: https://superuser.com/a/1619435

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment