Get all your news in one place.
100’s of premium titles.
One app.
Start reading
Windows Central
Windows Central
Technology
Richard Devine

How to fix Internet connectivity issues in WSL

Pinging Bing.com inside WSL on Windows 11

Much like Windows 11, without an active connection to the Internet the Windows Subsystem for Linux (WSL) will struggle to complete basic tasks such as updating packages. Exactly why your connection has disappeared could be a number of reasons, but the most important thing is getting it back. 

WSL hooks into your Windows PCs network connectivity but can suffer its own issues that can break it while your PC outside the Linux environment is still connected just fine. Fortunately, there's a fairly easy fix you can try that should get you back online. 

My own WSL suffered this exact fault recently, and this is how I fixed it.

How to fix connectivity issues for all distros installed on WSL

Even though you can have multiple distros installed on WSL, it's quite possible, and in my case, probable, to lose connectivity to them all at the same time. It became obvious when a simple update wasn't yielding any results, with the repos just hanging. You can also diagnose a connectivity problem using the ifconfig or ping commands. 

While we know the issue, how do we go about fixing it. Hat tip here to the Super User community for helping me figure it out. 

The first thing to try is entering the following commands into PowerShell as administrator. There's a suggestion to create a batch file, but honestly, copying and pasting all of the below into the terminal is all I needed to do.

wsl --shutdown
netsh winsock reset
netsh int ip reset all
netsh winhttp reset proxy
ipconfig /flushdns
netsh winsock reset
shutdown /r

What does this actually do? The short version is that it will shut down WSL, reset the network setting and flush the DNS. Once completed, launch your chosen WSL distro again and check connectivity. You can do something such as a sudo apt update or keep it even simpler and use ifconfig or ping bing.com. Hopefully, you'll now see results indicating your connectivity has returned.

If you have multiple distros installed, this should rectify the issue for all of them, too. Hopefully you're now back online. If the problem keeps recurring, it might be worth creating a batch file with the above commands in to make it quicker and simpler to apply the fix. 

Sign up to read this article
Read news from 100’s of titles, curated specifically for you.
Already a member? Sign in here
Related Stories
Top stories on inkl right now
Our Picks
Fourteen days free
Download the app
One app. One membership.
100+ trusted global sources.