Windows Subsystem for Linux (WSL2) is a powerful tool for developers that combines the best of Windows and Linux environments.
However, it’s not uncommon for users to encounter DNS issues, which can be frustrating and impact productivity.
In this article, we provide a comprehensive guide to troubleshooting and resolving WSL2 DNS not working issues.
Why Is WSL2 DNS Not Working?
- Service Interruptions: Temporary interruptions in WSL2 or networking services can cause DNS-related problems.
- Network Configuration Issues: Incorrect settings or misconfigurations in the network stack can lead to DNS resolution problems.
- Outdated Software: Running outdated versions of WSL2 or Windows can cause compatibility issues, including DNS problems.
- Firewall or Security Software: Overly restrictive firewall settings or security software configurations can block DNS traffic.

How To Fix WSL2 DNS Not Working?

1. Restart WSL2 And Networking Services
The first step in resolving DNS issues is to restart WSL2 and related networking services. This can clear temporary problems and restore functionality. Follow these steps:
- Close all WSL2 instances by running
wsl.exe --shutdown
in a Command Prompt or PowerShell window. - Restart the “Windows Subsystem for Linux” service by executing
net stop LxssManager
followed bynet start LxssManager
. - Reopen WSL2 and test the DNS functionality.
2. Check Network Configuration
Misconfigurations in network settings can cause DNS problems. Verify your network settings by following these steps:
- Open a WSL terminal and run
cat /etc/resolv.conf
to check the DNS configuration. - If the nameserver address is incorrect or missing, add the correct DNS server address using the
echo "nameserver <DNS_ADDRESS>" | sudo tee -a /etc/resolv.conf
command. - Test the DNS functionality again.
3. Update WSL2 And Windows
Outdated software can lead to compatibility issues, including DNS problems. Ensure both WSL and Windows are up-to-date:
- Update WSL by running
sudo apt update && sudo apt upgrade
in your Linux distribution. - Update Windows by going to Settings > Update & Security > Windows Update, and click “Check for updates.”
4. Manual DNS Configuration
Manually configuring the DNS settings in WSL2 can resolve some issues. To do this, follow these steps:
- Open a WSL terminal and run
sudo nano /etc/wsl.conf
- Add the following lines to the
wsl.conf
file:
[network] generateResolvConf = false
- Save and exit the editor by pressing
Ctrl + X
, thenY
, and finallyEnter
. - Restart WSL by running
wsl.exe --shutdown
in a Command Prompt or PowerShell window. - Reopen WSL and create a new
resolv.conf
file by runningsudo nano /etc/resolv.conf
. - Add the desired nameserver(s) to the file, using the format:
nameserver <DNS_ADDRESS>
- Save and exit the editor by pressing
Ctrl + X
, thenY
, and finallyEnter
. - Test the DNS functionality again.
5. Firewall And Security Software Settings
Overly restrictive firewall settings or security software configurations can block DNS traffic. Check your firewall and security software settings to ensure they are not interfering with WSL’s DNS functionality:
- Open your firewall or security software settings.
- Add exceptions for WSL and related processes, such as
wsl.exe
andLxssManager
. - Ensure that DNS traffic is allowed through the firewall.
- Test the DNS functionality in WSL2 again.
6. Reset Network Settings In Windows
If the issue persists after trying the above solutions, you can reset the network settings in Windows to their default values:
- Open the Settings app by pressing
Win + I
. - Navigate to Network & Internet > Status.
- Scroll down and click on “Network reset.”
- Click the “Reset now” button and confirm the action by clicking “Yes.”
- Restart your computer for the changes to take effect.
Please note that this will reset all network-related settings, including Wi-Fi and Ethernet configurations, so you may need to reconfigure your network connections after this step.
By following these comprehensive troubleshooting steps, you can effectively diagnose and resolve most WSL2 DNS issues, ensuring smooth operation and minimal downtime.
Similar Posts: