Skip to content

DNS issues in WSL2 #8365

Closed
Closed

Description

@OneBlue

Version

Multiple Windows builds are affected

WSL Version

  • WSL 2
  • WSL 1

This issue is here to merge DNS related issues in WSL2.

Symptoms include:

  • DNS resolution failing with Temporary failure in name resolution
  • DNS resolution timing out

This issue does not cover scenarios where /etc/resolv.conf is manually edited.

If you're hitting this, please upvote / comment and upload logs

Activity

  1. stijnherreman commented on May 4, 2022

    @stijnherreman

    Blue (@OneBlue) I've posted repro steps in #8236 for one of the causes.

  2. lbarbaglia commented on May 10, 2022

    @lbarbaglia

    Hi,
    I'm having the exact same issue so I've collected some logs in case it can help:
    WslLogs-2022-05-10_16-27-14.zip

    Even modifying the /etc/resolv.conf is not working anymore.

  3. CraigHutchinson commented on May 17, 2022

    @CraigHutchinson

    I am getting this issue on fresh installation of Windows 11 with WSL2 Ubuntu image, really annoying issue!

    [WSL] sudo apt update = ... Temporary failure resolving 'archive.ubuntu.com' ...
    [WSL] cat /etc/resolv.conf = ... nameserver 172.23.48.1
    [WSL] ping 172.23.48.1 = From 172.23.62.236 icmp_seq=3 Destination Host Unreachable
    [WSL] ping google.com = ping: google.com: Temporary failure in name resolution
    [Windows] ping 172.23.48.1 = Reply from 172.23.48.1: bytes=32 time<1ms TTL=128

    Attached are the logs.
    WslLogs-2022-05-17_10-17-13.zip

    NOTE: ON Windows 11 I got this error when running the capture so they may be incomplete?
    image

  4. r2evans commented on May 24, 2022

    @r2evans

    Craig Hutchinson (@CraigHutchinson) , your comment appears to mimic what I'm seeing, where the problem is somehow in the routing and not just the name resolution. Have you found any workarounds?

  5. MikaelUmaN commented on May 25, 2022

    @MikaelUmaN

    #4285 was already tracking this. I consider this issue the /dupe #4285

  6. BtbN commented on May 27, 2022

    @BtbN

    There were multiple open issues, all about the functionally same issue. Hence, as the initial description says, this exists to merge and declutter them.

  7. dlaudams commented on May 28, 2022

    @dlaudams

    There were multiple open issues, all about the functionally same issue. Hence, as the initial description says, this exists to merge and declutter them.

    If this leads to a fix, this is a great outcome.

    However the way it was handled may alienate the community. i.e., closing all the related issues without discussion or a clear reason provided in those issues.

  8. unowiz commented on May 29, 2022

    @unowiz

    It might be to do with Windows Defender settings. resolv.conf and wsl.conf based approach didn't work for me.
    sudo apt update && sudo apt upgrade worked immediately after I turned off the Private network firewall. Once the update completed, I've put the firewall for private network back on.

    On Windows 11, Go to Windows Security (from system tray, right click on Windows Security icon and select "View security dashboard" or simply search for "Firewall and network protection" after you press the windows key). Within the Firewall and network protection page, you should see Domain network (if domain connected), Private network, Public network. Go for the private network an turn it off temporarily as a workaround. Hope this helps.

  9. Shellishack commented on May 31, 2022

    @Shellishack

    I may have found another way to fix this. Originally I had this problem after using a proxy software. I just edited resolv.conf. It worked well until I realized that I also couldn't ping to Windows from WSL.

    For some reason, the vEthernet (WSL) adapter on my PC was treated as a public network. Disabling public firewall or turning off the option "block all incoming connections, including those in the list of allowed applications" in Control Panel fixed everything. I also attempted to change its connection profile to private using PowerShell, but Get-NetConnectionProfile can't even find it while both ipconfig and Get-NetIPconfiguration can display some limited info about it.

  10. zugazagoitia commented on Jun 2, 2022

    @zugazagoitia

    It might be to do with Windows Defender settings. resolv.conf and wsl.conf based approach didn't work for me. sudo apt update && sudo apt upgrade worked immediately after I turned off the Private network firewall. Once the update completed, I've put the firewall for private network back on.

    On Windows 11, Go to Windows Security (from system tray, right click on Windows Security icon and select "View security dashboard" or simply search for "Firewall and network protection" after you press the windows key). Within the Firewall and network protection page, you should see Domain network (if domain connected), Private network, Public network. Go for the private network an turn it off temporarily as a workaround. Hope this helps.

    This seems to be a fix for me too, Windows Firewall must be blocking DNS queries originating inside the WSL VM from reaching the DNS server at the host.

  11. Ray-Barker commented on Jun 3, 2022

    @Ray-Barker

    Tried to disable Windows Defender Firewall on Windows 10, doesn't help.
    Tried manually editing /etc/resolv.conf in my Ubuntu 20.04 WSL2 by adding 8.8.8.8 and 1.1.1.1, it helps, but these servers don't work in our VPN.
    What helped me as a workaround was adding my router's IP as a nameserver to resolv.conf since it has DNS server capability.
    But I would like a more generalized solution.

  12. mbwhite commented on Jun 8, 2022

    @mbwhite

    Windows 10 with Ubuntu 20 in WSL2 : got some reproducible failures today for the first time; and it's confirmed something I've suspected but never been able to prove.. that there might be a connection with running the docker daemon.

    Everything is working correctly (as fas as DNS goes), start the docker daemon (just a plain sudo dockerd ) afterwards, the 'temporary failure' error occurs.

    Logs attached.
    WslLogs-2022-06-08_16-56-39.zip

  13. jikuja commented on Jun 14, 2022

    @jikuja

    For me #7555 gave really good pointers for fixing the issue.

    Fixes that works for me:

    • Disabling defender for public profile fixes DNS issue
    • or removal of vEthernet(WSL) network connection on public profile settings also fixes the DNS issue

    I cannot recommend either of those to anyone because the first solution just breaks security and the second one might open some vulnerabilites.

  14. 93 remaining items

  15. levzlotnik commented on Jun 23, 2024

    @levzlotnik

    This appeared suddenly today, last time I tried (a few weeks ago) it had no such issues.

    So just undo any changes you did to your setup during these few weeks.

    I hadn't made any changes myself, I assume the changes came from some automatic updates to Windows settings. So I don't really know what changed.
    It's not really a big deal for me as I can still connect through Windows' SSH. I just reported that this was an issue for me that's related to this thread.

  16. danielfdickinson commented on Aug 11, 2024

    @danielfdickinson

    This is just an FYI, I have worked around the issues and have things working (latest Windows 11 normal--non-insiders--channel).

    1. With dnsTunneling=true (or not set as this is the default) in both NAT and mirrored network modes, nslookup github.com only succeeds for the first of the three queries it makes.
      • I suspect this is due to having DoH enabled on all my networks in the Windows host networking.
    2. In order to disable dnsTuneling for mirrored network mode, one has to first set
    networkMode=NAT
    dnsTunneling=false

    then do a wsl --shutdown, start wsl, and shut it down again, then set

    networkMode=mirrored
    dnsTunneling=false

    Then the next time you start wsl the 10.255.255.254 address on the loopback will no longer be there. If you just skip to the dnsTunneling=false and networkMode=mirrored in one step the dns tunneling remains active and the 10.255.255.254 address is still present.

    HTH

  17. OscBacon commented on Nov 6, 2024

    @OscBacon

    Hey, I also run into issues when using mirrored mode (dnsTunneling set to true or false), and switch wifi connections.
    So far, seems like the only fix is to stick to NAT mode?
    Any other possible fixes?
    Daniel F. Dickinson (@danielfdickinson) tried switching off dnsTunneling in two steps, but no luck

    Also, DNS issues happen on my end with no VPN involved

  18. djordje47 commented on May 12, 2025

    @djordje47

    Hi everyone, I've read all the comments briefly, so don't hate me if I miss something. I had a DNS problem with the local projects not being able to be resolved with the fake domain name.

    So, in a nutshell, I have the following env.

    WSL2 & LAMP stack on it. Then on Windows, I modify the hosts file like so:
    ::1 shipment.development localhost

    It was working until some update, but then it stopped.

    My temporary solution is the following:

    1. Get the IP address of the wsl when I start it with this command: ip addr show eth0 | grep inet
    2. Then I modify my hosts file on Windows like this: <the_wsl_ip_address> shipment.development

    This works for me now, but if you have some other solution, I am all ears. By the way strange thing the previous hosts file modification works with some VPN enabled, but why, I don't know.

    I didn't have time to check it more thoroughly, but when I get the chance, I will.

    Hope this helps someone, cheers!

  19. anudeepx commented on Oct 30, 2025

    @anudeepx

    WSL2: Temporary failure in name resolution even after setting static DNS and disabling generateResolvConf

    What I’ve tried

    • Set static DNS manually (8.8.8.8 and Windows gateway)
    • Disabled auto-generation of resolv.conf
    • Flushed DNS and reset Winsock
    • Rebooted multiple times

    Results

    • ping 8.8.8.8 → works
    • ping google.com → fails
    • /etc/resolv.conf is correct but ignored by WSL
    • .wslconfig triggers: Unknown key 'network.generateResolvConf' in C:\Users\avula\.wslconfig
  20. onomatopellan commented on Oct 31, 2025

    @onomatopellan

    @0x4nud33p beware generateResolvConf is something you add to /etc/wsl.conf in the distro and not in .wslconfig. Also you shouldn't disable it if you are in Windows 11 and using DNS tunneling.

    If you really need to configure .wslconfig I recommend the "WSL Settings" app that comes with latest version of WSL.

  21. anudeepx commented on Oct 31, 2025

    @anudeepx

    Fresh WSL install but can’t reach the internet, even though Windows networking works fine. I can ping from Windows successfully, but inside WSL all packets are lost.

    PS C:\WINDOWS\system32> wsl --version
    WSL version: 2.6.1.0
    Kernel version: 6.6.87.2-1
    WSLg version: 1.0.66
    MSRDC version: 1.2.6353
    Direct3D version: 1.611.1-81528511
    DXCore version: 10.0.26100.1-240331-1435.ge-release
    Windows version: 10.0.26200.6899
    
    PS C:\WINDOWS\system32> wsl
    anudeep@AsusVivobook16x:/mnt/c/WINDOWS/system32$ ping google.com
    PING google.com (142.251.222.174) 56(84) bytes of data.
    ^C
    --- google.com ping statistics ---
    24 packets transmitted, 0 received, 100% packet loss, time 23548ms
    
    anudeep@AsusVivobook16x:/mnt/c/WINDOWS/system32$ exit
    logout
    
    PS C:\WINDOWS\system32> ping google.com
    
    Pinging google.com [2404:6800:4002:80e::200e] with 32 bytes of data:
    Reply from 2404:6800:4002:80e::200e: time=75ms
    Reply from 2404:6800:4002:80e::200e: time=75ms
    Reply from 2404:6800:4002:80e::200e: time=78ms
    Reply from 2404:6800:4002:80e::200e: time=84ms
    
    Ping statistics for 2404:6800:4002:80e::200e:
        Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
    Approximate round trip times in milli-seconds:
        Minimum = 75ms, Maximum = 84ms, Average = 78ms
    

    @0x4nud33p beware generateResolvConf is something you add to /etc/wsl.conf in the distro and not in .wslconfig. Also you shouldn't disable it if you are in Windows 11 and using DNS tunneling.

    If you really need to configure .wslconfig I recommend the "WSL Settings" app that comes with latest version of WSL.

  22. onomatopellan commented on Oct 31, 2025

    @onomatopellan

    @0x4nud33p I see you have prioritized IPv6 on Windows. Inside WSL, does something like ping 142.251.222.174 work? What's the output for ifconfig?

    I need you to go to Start menu and open the app "WSL Settings". In the Networking section make sure your networking mode is "Mirrored", you have enabled DNS tunneling and optionally DNS best effort parsing.
    Remember to restart WSL with wsl.exe --shutdown to see the changes.

  23. anudeepx commented on Oct 31, 2025

    @anudeepx

    ping 142.251.222.174

    Jonathan (@onomatopellan)

    • ping 142.251.222.174 hangs!
    PS C:\Users\avula> wsl
    anudeep@AsusVivobook16x:/mnt/c/Users/avula$ ping 142.251.222.174
    PING 142.251.222.174 (142.251.222.174) 56(84) bytes of data.
    • output of ipconfig:
    PS C:\Users\avula> ipconfig
    
    Windows IP Configuration
    
    
    Unknown adapter McAfee VPN:
    
       Media State . . . . . . . . . . . : Media disconnected
       Connection-specific DNS Suffix  . :
    
    Wireless LAN adapter Local Area Connection* 1:
    
       Media State . . . . . . . . . . . : Media disconnected
       Connection-specific DNS Suffix  . :
    
    Wireless LAN adapter Local Area Connection* 2:
    
       Media State . . . . . . . . . . . : Media disconnected
       Connection-specific DNS Suffix  . :
    
    Wireless LAN adapter Wi-Fi:
    
       Connection-specific DNS Suffix  . :
       IPv6 Address. . . . . . . . . . . : 2409:40f0:dc:1ce6:b33c:17ec:4a8b:fe81
       Temporary IPv6 Address. . . . . . : 2409:40f0:dc:1ce6:4c20:b5ba:4082:6c75
       Link-local IPv6 Address . . . . . : fe80::c8da:3c9b:7a0c:160%8
       Autoconfiguration IPv4 Address. . : 169.254.120.29
       Subnet Mask . . . . . . . . . . . : 255.255.0.0
       Default Gateway . . . . . . . . . : fe80::d82a:2aff:fe82:f462%8
    
    Ethernet adapter vEthernet (WSL (Hyper-V firewall)):
    
       Connection-specific DNS Suffix  . :
       Link-local IPv6 Address . . . . . : fe80::6cfd:c0f9:980a:a4f0%42
       IPv4 Address. . . . . . . . . . . : 172.22.128.1
       Subnet Mask . . . . . . . . . . . : 255.255.240.0
       Default Gateway . . . . . . . . . :
    PS C:\Users\avula>
    • edited /etc/wsl.conf to:
    [network]
    generateResolvConf = false
    
    • output:
    anudeep@AsusVivobook16x:/mnt/c/WINDOWS/SystemApps/MicrosoftWindows.Client.CBS_cw5n1h2txyewy$ sudo nano /etc/wsl.conf
    [sudo] password for anudeep:
    anudeep@AsusVivobook16x:/mnt/c/WINDOWS/SystemApps/MicrosoftWindows.Client.CBS_cw5n1h2txyewy$ sudo nano /etc/wsl.conf
    anudeep@AsusVivobook16x:/mnt/c/WINDOWS/SystemApps/MicrosoftWindows.Client.CBS_cw5n1h2txyewy$ sudo rm /etc/resolv.conf
    echo "nameserver 8.8.8.8" | sudo tee /etc/resolv.conf
    nameserver 8.8.8.8
    • even after trying all commands:
    PS C:\Users\avula> wsl.exe --shutdown
    PS C:\Users\avula> ping google.com
    
    Pinging google.com [2404:6800:4007:833::200e] with 32 bytes of data:
    Reply from 2404:6800:4007:833::200e: time=40ms
    Reply from 2404:6800:4007:833::200e: time=48ms
    Reply from 2404:6800:4007:833::200e: time=39ms
    Reply from 2404:6800:4007:833::200e: time=261ms
    
    Ping statistics for 2404:6800:4007:833::200e:
        Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
    Approximate round trip times in milli-seconds:
        Minimum = 39ms, Maximum = 261ms, Average = 97ms
    PS C:\Users\avula> wsl
    wsl: Invalid boolean value 'fasle' for key 'network.generateResolvConf' in /etc/wsl.conf:2
    anudeep@AsusVivobook16x:/mnt/c/Users/avula$ ping google.com
    PING google.com (172.217.24.238) 56(84) bytes of data.
    ^X^C
    --- google.com ping statistics ---
    60 packets transmitted, 0 received, 100% packet loss, time 60420ms
    
    anudeep@AsusVivobook16x:/mnt/c/Users/avula$

    I do not have the “WSL Settings” app on my system I cannot access networking options through that app.

    @0x4nud33p I see you have prioritized IPv6 on Windows. Inside WSL, does something like ping 142.251.222.174 work? What's the output for ifconfig?

    I need you to go to Start menu and open the app "WSL Settings". In the Networking section make sure your networking mode is "Mirrored", you have enabled DNS tunneling and optionally DNS best effort parsing. Remember to restart WSL with wsl.exe --shutdown to see the changes.

  24. onomatopellan commented on Oct 31, 2025

    @onomatopellan

    @0x4nud33p You can get the networking mode from inside WSL with wslinfo --networking-mode. Is it mirrored?

  25. anudeepx commented on Oct 31, 2025

    @anudeepx

    @0x4nud33p You can get the networking mode from inside WSL with wslinfo --networking-mode. Is it mirrored?
    Jonathan (@onomatopellan)

    anudeep@AsusVivobook16x:/mnt/c/Users/avula$ wslinfo --networking-mode
    nat

    It shows my WSL instance is using the default NAT networking mode, not mirrored.
    I don’t have the “WSL Settings” app available on my system to change this mode through the UI.

  26. onomatopellan commented on Oct 31, 2025

    @onomatopellan

    @0x4nud33p It's weird. it should be in C:\Program Files\WSL\wslsettings\

    Anyway you need mirrored networking. In Windows 11 edit the .wslconfig file in the Users folder with this content:

    [wsl2]
    networkingMode=Mirrored
    

    Then wsl.exe --shutdown and try again.

  27. anudeepx commented on Oct 31, 2025

    @anudeepx

    It worked. Appreciate the guidance Jonathan (@onomatopellan)

  28. microsoft-github-policy-service commented on Nov 5, 2026

    @microsoft-github-policy-service
    Contributor

    This issue has been automatically closed since it has not had any activity for the past year. If you're still experiencing this issue please re-file this as a new issue or feature request.

    Thank you!

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

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions