4] Turn Off Windows Firewall or Other Security Software
Windows firewalls or other security software that blocks or restricts WSL 2 internet access can also cause Internet connection problems in WSL 2. Windows Firewall is a feature that aims to protect your computer from unauthorized network attacks, but sometimes it can also interfere with legitimate internet connections.
To fix this, you can try to turn off the Windows firewall or other security software you are using temporarily, and see if your internet connection is up and running in WSL 2. If yes, then you need to add an exception for WSL 2 on the Windows firewall or other security software to avoid being blocked again.
To turn off the Windows firewall, you can go to Control Panel > System and Security > Windows Defender Firewall and click Turn Windows Defender Firewall on or off. Then, select the Turn off Windows Defender Firewall (not recommended) option for each existing network profile.
To add an exception for WSL 2 on the Windows firewall, you can go to Control Panel > System and Security > Windows Defender Firewall and click Allow an app or feature through Windows Defender Firewall. Then, click Change settings and check the WSL box on the list of existing apps and features.
To turn off or add exceptions for other security software you use, please follow the instructions of that software provider.
After turning off the Windows firewall or other security software, or adding exceptions for WSL 2, try checking again that your internet connection is normal in WSL 2. If you’re still having trouble, move on to the next solution.
5] Reset WSL 2 Network Settings
If the previous solutions did not work to fix the internet connection problem in WSL 2, then the last step you can try is to reset the WSL 2 network settings to the initial state. This will remove any network configurations you’ve created or changed before, and create WSL 2 using the default network settings set by Windows 11.
To reset WSL 2 network settings, you need to run the following command in PowerShell as an administrator:
wsl –shutdown netsh winsock reset netsh int ip reset all netsh winhttp reset proxy ipconfig /flushdns
These commands will shut down all Linux distributions running on WSL 2, and reset Windows 11 network settings. Once done, you need to restart your computer for the changes to take effect.
After restarting your computer, try checking again if your internet connection is normal in WSL 2. If yes, then congratulations, you have successfully fixed the internet connection issue in WSL 2. If not, then there may be other issues that cannot be solved by the above means, and you need to seek further help from the WSL 2 or Microsoft community.
Conclusion
Internet connection issues in WSL 2 Ubuntu Windows 11 are one of the problems often experienced by WSL 2 users. This issue can be caused by various factors, such as incorrect or inappropriate network configurations, conflicts between Windows firewalls and WSL 2, bugs or errors in the version of WSL 2 or Windows 11 used, or interference with DNS or DHCP services.
To fix this problem, you can try some of the solutions we have described above, namely:
- Check the status of your internet connection
- Update WSL 2 and Windows 11 to the latest version
- Customize WSL 2 network configuration globally or specifically
- Turn off the Windows firewall or other security software
- Reset WSL 2 network settings
We hope this article can help you solve internet connection issues on WSL 2 Ubuntu Windows 11. Thank you for reading this article.