After cumulative updates on my Windows 11 computer, I ran into this issue:
Wsl/Service/CreateInstance/CreateVm/ConfigureNetworking/HNS/E_ACCESSDENIED
and WSL exited with code -1
For reference, my WSL environment is
Ubuntu version: 22.04.3 LTS
Windows version: 10.0.26100.2152
I'm writing this here so that I don't need to search so dilligently again to find this information
To fix the issue, I
- Closed any instance of WSL that was open
- Opened PowerShell as an Administrator
- Ran the following commands -
- Remove the network so that it can be rebuilt
Get-HnsNetwork | Remove-HnsNetwork
- Shutdown WSL
Stop-Service hns
Start-Service hns
wsl --shutdown
- Disable the platform
dism.exe /online /disable-feature /featurename:VirtualMachinePlatform /norestart
dism.exe /online /disable-feature /featurename:Microsoft-Windows-Subsystem-Linux /norestart
- Re-Enable the platform
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /norestart
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /norestart
- Remove the network so that it can be rebuilt
At this point, I re-launched WSL in my terminal and it worked, and I re-launched it in VS Code, and it worked