How to fix Internet connectivity issues in WSL
If your WSL instance has lost connectivity to the Internet, then there should be an easy fix to get back online.
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.
Get the Windows Central Newsletter
All the latest news, reviews, and guides for Windows and Xbox diehards.
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.
Richard Devine is a Managing Editor at Windows Central with over a decade of experience. A former Project Manager and long-term tech addict, he joined Mobile Nations in 2011 and has been found on Android Central and iMore as well as Windows Central. Currently, you'll find him steering the site's coverage of all manner of PC hardware and reviews. Find him on Mastodon at mstdn.social/@richdevine