Skip to content

Instantly share code, notes, and snippets.

@dsmith73
Last active October 11, 2024 09:32
Show Gist options
  • Save dsmith73/84ce01d1cde0983b8ccf4ae84a881e5f to your computer and use it in GitHub Desktop.
Save dsmith73/84ce01d1cde0983b8ccf4ae84a881e5f to your computer and use it in GitHub Desktop.
Wsl/Service/CreateInstance/CreateVm/ConfigureNetworking/HNS/E_ACCESSDENIED

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

At this point, I re-launched WSL in my terminal and it worked, and I re-launched it in VS Code, and it worked

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