The network name can not be found
Version
Microsoft Windows [Version 10.0.19044.1415]
WSL Version
- [X] WSL 2
- [ ] WSL 1
Kernel Version
5.10.60.1-microsoft-standard-WSL2
Distro Version
Ubuntu 21.04
Other Software
Windows Terminal, Version: 1.11.3471.0
Repro Steps
- Open Windows Terminal with Windows.Terminal.Wsl
Expected Behavior
The terminal should open inside my Ubuntu distro
Actual Behavior
Sometimes I get "The network name can not be found" and the terminal immediately exits. I think it is a race condition, since this does not always happen. But when it does, I can not start Windows Terminal with Windows.Terminal.Wsl at all, until wsl is started.
My work-around is to open PowerShell and write wsl -d Ubuntu. After that, I can open Windows Terminal as usual.
Diagnostic Logs
Same problem
I have a same problem when startingDirectory set as "\\\\wsl$\\DISTRO NAME\\home\\USERNAME".
resolve: use commandline: wsl ~ or wsl -d DISTRO --cd ~
like this:

@fyxw was right. I change the Starting diretory to default value, which is %USERPROFILE%, problem solved
I have a same problem when
startingDirectoryset as"\\\\wsl$\\DISTRO NAME\\home\\USERNAME".resolve: use
commandline: wsl ~orwsl -d DISTRO --cd ~like this:
This seemingly solved the problem for me.
I was using Windows Terminal. In its Settings > Profiles > Ubuntu-20.04 > General, I had Command Line set to wsl.exe -d Ubuntu-20.04 and Starting Directory set to the absolute path through the windows filesystem to the wsl2 /home/[user] (with backslashes). Changing Starting Directory to %USERPROFILE% stopped the error occurring, but meant the bash opened up in my windows user directory I think. Then appending --cd ~ to the Command Line argument meant I was back to opening up the bash in my wsl2 ubuntu user directory.
thanks @fyxw - now it works for me.
I still feel this issue should stay open as this is a regression. It's not obvious why this is happening only that the work-around is to have either wsl.exe ~ or wsl.exe -d DISTRO --cd ~ in the Command line field in settings.
The default value for Command line is wsl.exe -d Ubuntu on my system.
Unfortunately, I just got the following error message:
[error 0x8007010b when launching `wsl.exe -d Ubuntu --cd ~']
Could not access starting directory "\\wsl$\Ubuntu\home\dotnet"
So the work-around does not work for me. :(
Unfortunately, I just got the following error message:
[error 0x8007010b when launching `wsl.exe -d Ubuntu --cd ~'] Could not access starting directory "\\wsl$\Ubuntu\home\dotnet"So the work-around does not work for me. :(
Did you set the startingDirectory to %USERPROFILE% or other windows path, if startingDirectory is a network path, may cause it. \\wsl$\Ubuntu\xxx\ is a network path, it may not exist when wsl is closed.
Hi @fyxw. No, I had startingDirectory sat to \\wsl$\Ubuntu\xxx\. Changing that to the default %USERPROFILE% and Command line to wsl.exe ~ seems to fix my issue. Thanks!
In my case, this was caused by having \\wsl.localhost\Ubuntu\home\username set as the startingDirectory and unknowingly having Virtualisation turned off in my UEFI.
It wasn't until I changed startingDirectory back to %USERPROFILE% that WSL correctly told me that Virtualisation had been turned off.
yeah i did wsl -update and thise network error happened. solution worked
I had to restart Windows after changing the commandline and startingDirectory settings. Worked perfectly after the restart.
Make sure Virtualization is enabled in BIOS (that's what it's called for intel CPU's) especially if you've been recently messing with your BIOS settings.