microsoft / WSL

Issues found on WSL
https://docs.microsoft.com/windows/wsl
MIT License
17.48k stars 822 forks source link

WSL2 cannot able to start, Error: 0x80041002 #12019

Closed 3265 closed 2 months ago

3265 commented 2 months ago

Windows Version

Microsoft Windows [Version 10.0.22631.4169]

WSL Version

2.2.4.0

Are you using WSL 1 or WSL 2?

Kernel Version

5.15.153.1-2

Distro Version

Ubuntu

Other Software

No response

Repro Steps

Trying to start the WSL application

Expected Behavior

Should be able to start normally

Actual Behavior

Cannot able to start with following error.

Failed to configure network (networkingMode Nat). To disable networking, set `wsl2.networkingMode=None` in C:\Users\mgold\.wslconfig
Error code: Wsl/Service/CreateInstance/CreateVm/ConfigureNetworking/HNS/0x80041002
Press any key to continue...

Diagnostic Logs

Here is the log by collect-wsl-logs.ps1.

WslLogs-2024-09-11_20-55-05.zip

github-actions[bot] commented 2 months ago

The logs show that the VM failed to start because the HNS network couldn't be created. Adding network tag Known vmswitch issue found (error: 0x80041002). Adding network tag

Diagnostic information ``` .wslconfig found Detected appx version: 2.2.4.0 Detected user visible error: Wsl/Service/CreateInstance/CreateVm/ConfigureNetworking/HNS/0x80041002 Found evidence of HcnCreateNetwork failure: HcnCreateNetwork (null). HResult: 0x80041002 Found evidence of vmswitch error: 0x80041002 ```
3265 commented 2 months ago

Maybe this is the full error message?

Event Viewer > Applications and Services Logs > Microsoft > Windows > Hyper-V-VMMS > Admin

image

Log Name:      Microsoft-Windows-Hyper-V-VMMS-Admin
Source:        Microsoft-Windows-Hyper-V-VMMS
Date:          9/11/2024 8:29:25 PM
Event ID:      16000
Task Category: None
Level:         Error
Keywords:      
User:          SYSTEM
Computer:      DESKTOP-017FR51
Description:
The Hyper-V Virtual Machine Management service encountered an unexpected error: Not found (0x80041002).
Event Xml:
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
  <System>
    <Provider Name="Microsoft-Windows-Hyper-V-VMMS" Guid="{6066f867-7ca1-4418-85fd-36e3f9c0600c}" />
    <EventID>16000</EventID>
    <Version>0</Version>
    <Level>2</Level>
    <Task>0</Task>
    <Opcode>0</Opcode>
    <Keywords>0x8000000000000000</Keywords>
    <TimeCreated SystemTime="2024-09-11T11:29:25.1390872Z" />
    <EventRecordID>41</EventRecordID>
    <Correlation ActivityID="{4e74b314-040e-0006-0cb6-744e0e04db01}" />
    <Execution ProcessID="3360" ThreadID="2720" />
    <Channel>Microsoft-Windows-Hyper-V-VMMS-Admin</Channel>
    <Computer>DESKTOP-017FR51</Computer>
    <Security UserID="S-1-5-18" />
  </System>
  <UserData>
    <VmlEventLog xmlns="http://www.microsoft.com/Windows/Virtualization/Events">
      <ErrorMessage>%%2147749890</ErrorMessage>
      <ErrorCode>0x80041002</ErrorCode>
    </VmlEventLog>
  </UserData>
</Event>
3265 commented 2 months ago

I added the following config to C:\Users\XXXX\.wslconfig which made the launch successful:

[wsl2]
networkingMode=none

Then I made a backup file and uninstalled Ubuntu. However, when I tried to reinstall Ubuntu or similar distributions, I got the following error:

Installing, this may take a few minutes...
WslRegisterDistribution failed with error: 0x80041002
Error: 0x80041002 (null)
Press any key to continue...

umnn

3265 commented 2 months ago

I disabled Hyper-V in windows features.

And I executed command below:

$ wsl --uninstall

And

$ wsl.exe --update

And re-executed the install command.

$ wsl --install Ubuntu

But i got the same error (0x80041002)

3265 commented 2 months ago

image

Creating a virtual switch (as admin) also had same error code.

[Window Title]
Virtual Switch Manager for DESKTOP-017FR51

[Main Instruction]
Error applying Virtual Switch Properties changes

[Content]
仮想イーサネット スイッチの作成中にエラーが発生しました。

[Expanded Information]
スイッチの作成に失敗しました。名前 = 'E59F478C-802D-428B-A5F0-3AE48AAA8880'、フレンドリ名 = 'New Virtual Switch': %%2147749890 (0x80041002)。

[^] Hide details  [Close]

this is hyper-v problem obviously.

PS C:\WINDOWS\system32> New-VMSwitch -Name "TestSwitch" -SwitchType Internal
New-VMSwitch : Failed while creating virtual Ethernet switch.
Switch create failed, name = 'A7B01F05-DB6A-499F-9861-A14E742D2EA1', friendly name = 'TestSwitch': %%2147749890
(0x80041002).
At line:1 char:1
+ New-VMSwitch -Name "TestSwitch" -SwitchType Internal
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [New-VMSwitch], VirtualizationException
    + FullyQualifiedErrorId : Unspecified,Microsoft.HyperV.PowerShell.Commands.NewVMSwitch
PS C:\WINDOWS\system32> Get-WinEvent -LogName "Microsoft-Windows-Hyper-V-VMMS-Admin" -MaxEvents 10
   ProviderName: Microsoft-Windows-Hyper-V-VMMS
TimeCreated                      Id LevelDisplayName Message
-----------                      -- ---------------- -------
9/11/2024 11:43:33 PM         16000 Error            The Hyper-V Virtual Machine Management service encountered an unexpected error: Not found (0x80041002).
9/11/2024 11:43:09 PM         16000 Error            The Hyper-V Virtual Machine Management service encountered an unexpected error: Not found (0x80041002).
9/11/2024 11:42:44 PM         19020 Information      The WMI provider 'VmmsWmiEventProvider' has started.
9/11/2024 11:42:44 PM         19020 Information      The WMI provider 'VmmsWmiInstanceAndMethodProvider' has started.
9/11/2024 11:42:44 PM         14094 Information      Virtual Machine Management service is started successfully.
9/11/2024 11:42:44 PM         33483 Information      Incremental Replication will timeout after 360 hours. Minimum value for timeout is 6 hours.
9/11/2024 11:42:44 PM         33834 Information      Hyper-V would age out CDP reference points after 720 hours.
9/11/2024 11:42:44 PM         33481 Information      Change tracking has defined following limits for pending log file size....
9/11/2024 11:42:44 PM         33480 Information      Change tracking has defined following limits for free disk space....
9/11/2024 11:42:44 PM         20410 Information      Successfully started the Virtual Machine migration connection manager.
3265 commented 2 months ago

I successfully used wsl 1 (by wsl --set-default-version 1) since it doesn't require Hyper-V. However, for my office environment, it might be more beneficial to run an Ubuntu server on the LAN and use Windows as a client to access it.