WSL: Winsock module breaks WSL2

For an workaround provided by Proxifier, see https://github.com/microsoft/WSL/issues/4177#issuecomment-597736482

Please fill out the below information:

  • Your Windows build number: 10.0.18917.1000

  • What you’re doing and what’s happening:
    After updating from 1903 to 18917, I upgraded to WSL2 and it works fine. Later, I enabled https://www.proxifier.com/'s winsock module in its “System Setting 64-bit” app, and WSL2 starting to fail with The attempted operation is not supported for the type of object referenced..

⚡ Liqueur Librazy C:\..\system32 ❯❯❯ wsl
The attempted operation is not supported for the type of object referenced.
⚡ Liqueur Librazy C:\..\system32 ❯❯❯ wsl -l -v
NAME            STATE           VERSION
* Ubuntu-18.04    Running         2
⚡ Liqueur Librazy C:\..\system32 ❯❯❯ wsl --shutdown 
⚡ Liqueur Librazy C:\..\system32 ❯❯❯ wsl -l -v 
NAME            STATE           VERSION
* Ubuntu-18.04    Stopped         2
⚡ Liqueur Librazy C:\..\system32 ❯❯❯ wsl
The attempted operation is not supported for the type of object referenced.
⚡ Liqueur Librazy C:\..\system32 ❯❯❯ wsl -l -v
NAME            STATE           VERSION
* Ubuntu-18.04    Running         2
⚡ Liqueur Librazy C:\..\system32 ❯❯❯ wsl -l -v
NAME            STATE           VERSION
* Ubuntu-18.04    Stopped         2
⚡ Liqueur Librazy C:\..\system32 ❯❯❯ wsl
The attempted operation is not supported for the type of object referenced.
⚡ Liqueur Librazy C:\..\system32 ❯❯❯ wsl -l -v
NAME            STATE           VERSION
* Ubuntu-18.04    Running         2
⚡ Liqueur Librazy C:\..\system32 ❯❯❯ wsl
The attempted operation is not supported for the type of object referenced.

After uninstalling the winsock module, WSL2 launches again. And installing the winsock module won’t cause running WSL2 console to fail.

  • What’s wrong / what should be happening instead:

WSL2 should work even if there are other winsock modules installed.

lxcore.zip

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 34
  • Comments: 95 (8 by maintainers)

Commits related to this issue

Most upvoted comments

Developers of Proxifier told me the reason and gave me a solution.

Thanks for the info.

We have reproduced this issue. Apparently, wsl.exe displays this error if Winsock LSP DLL gets loaded into its process.

The easiest solution is to use WSCSetApplicationCategory WinAPI call for wsl.exe to prevent this. Under the hood the call creates an entry for wsl.exe at HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\WinSock2\Parameters\AppId_Catalog This tells Windows not to load LSP DLLs into wsl.exe process.

We have a tool that can make this call: www.proxifier.com/tmp/Test20200228/NoLsp.exe

Please just run as admin with the full path to wsl.exe as the parameter: NoLsp.exe c:\windows\system32\wsl.exe

This has fixed the problem in my case.

Please let me know how it works for you.

And it works well for me!

The same issue. After running a game speedup VPN (https://uu.163.com), WSL2 cannot running. Reset winsock can fix it.

PS C:\WINDOWS\system32> wsl.exe --shutdown
PS C:\WINDOWS\system32> wsl.exe
The attempted operation is not supported for the type of object referenced.
PS C:\WINDOWS\system32> netsh winsock reset

Sucessfully reset the Winsock Catalog.
You must restart the computer in order to complete the reset.

PS C:\WINDOWS\system32> wsl.exe
root@TIGERHOMEPC /mnt/c/Windows/System32
  # exit

Build 18922.1000.

Sorry for a useless comment. Developers in China highly rely on proxies due to poor network condition. I do hope this issue will be resolved soon.

Developers of Proxifier told me the reason and gave me a solution.

Thanks for the info. We have reproduced this issue. Apparently, wsl.exe displays this error if Winsock LSP DLL gets loaded into its process. The easiest solution is to use WSCSetApplicationCategory WinAPI call for wsl.exe to prevent this. Under the hood the call creates an entry for wsl.exe at HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\WinSock2\Parameters\AppId_Catalog This tells Windows not to load LSP DLLs into wsl.exe process. We have a tool that can make this call: www.proxifier.com/tmp/Test20200228/NoLsp.exe Please just run as admin with the full path to wsl.exe as the parameter: NoLsp.exe c:\windows\system32\wsl.exe This has fixed the problem in my case. Please let me know how it works for you.

And it works well for me!

@1160300208 Thanks you! It works for me (19564.1005).

S'all good, man

Works for me, steps:

  1. Run powershell as Administrator.
  2. Run command .\NoLsp.exe c:\windows\system32\wsl.exe Then you well see return: Success!

The same issue. After running a game speedup VPN (https://uu.163.com), WSL2 cannot running. Reset winsock can fix it.

PS C:\WINDOWS\system32> wsl.exe --shutdown
PS C:\WINDOWS\system32> wsl.exe
The attempted operation is not supported for the type of object referenced.
PS C:\WINDOWS\system32> netsh winsock reset

Sucessfully reset the Winsock Catalog.
You must restart the computer in order to complete the reset.

PS C:\WINDOWS\system32> wsl.exe
root@TIGERHOMEPC /mnt/c/Windows/System32
  # exit

Build 18922.1000.

I encounter this problem and use this method to solve. But my proxifier can’t be used.

There are some caveats for NoLsp.exe.

  1. Full path must be specified. It doesn’t check if wsl.exe exists or not.
  2. Every time Microsoft Store version WSL updates, you’ll need to run it manually.

So I created this script to run on boot. I have tested and now it works without issue. (Please remember to kill wslservice.exe if it doesn’t work)

#Requires -RunAsAdministrator
# Fix for https://github.com/microsoft/WSL/issues/4177

$MethodDefinition = @'
[DllImport("ws2_32.dll", CharSet = CharSet.Unicode)]
public static extern int WSCSetApplicationCategory([MarshalAs(UnmanagedType.LPWStr)] string Path, uint PathLength, [MarshalAs(UnmanagedType.LPWStr)] string Extra, uint ExtraLength, uint PermittedLspCategories, out uint pPrevPermLspCat, out int lpErrno);
'@

$Ws2Spi = Add-Type -MemberDefinition $MethodDefinition -Name 'Ws2Spi' -PassThru

$WslLocation = Get-AppxPackage MicrosoftCorporationII.WindowsSubsystemForLinux | Select-Object -expand InstallLocation

$Executables = ("wsl.exe", "wslservice.exe");

foreach ($Exe in $Executables) {
    $ExePath = "${WslLocation}\${Exe}";
    $ExePathLength = $ExePath.Length;

    $PrevCat = $null;
    $ErrNo = $null;
    if ($Ws2Spi::WSCSetApplicationCategory($ExePath, $ExePathLength, $null, 0, [uint32]"0x80000000", [ref] $PrevCat, [ref] $ErrNo) -eq 0) {
        Write-Output "Added $ExePath!";
    }
}

Proxifier的开发人员告诉了我原因,并给了我一个解决方案。

谢谢(你的)信息。 我们已转载此问题。 显然,如果Winsock LSP DLL被加载到其进程中,则wsl.exe将显示此错误。 最简单的解决方案是对wsl.exe使用WSCSetApplicationCategory WinAPI调用来防止这种情况。 在幕后,该调用在HKEY_LOCAL_MACHINE \ SYSTEM \ CurrentControlSet \ Services \ WinSock2 \ Parameters \ AppId_Catalog中为wsl.exe创建一个条目。 这告诉Windows不要将LSP DLL加载到wsl.exe进程中。 我们有一个可以进行此调用的工具: www.proxifier.com/tmp/Test20200228/NoLsp.exe 请以管理员身份运行,并以wsl.exe的完整路径作为参数: NoLsp.exe c:\ windows \ system32 \ wsl.exe 这已经解决了我的问题。 请让我知道它如何为您工作。

它对我来说很好!

Developers of Proxifier told me the reason and gave me a solution.

Thanks for the info. We have reproduced this issue. Apparently, wsl.exe displays this error if Winsock LSP DLL gets loaded into its process. The easiest solution is to use WSCSetApplicationCategory WinAPI call for wsl.exe to prevent this. Under the hood the call creates an entry for wsl.exe at HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\WinSock2\Parameters\AppId_Catalog This tells Windows not to load LSP DLLs into wsl.exe process. We have a tool that can make this call: www.proxifier.com/tmp/Test20200228/NoLsp.exe Please just run as admin with the full path to wsl.exe as the parameter: NoLsp.exe c:\windows\system32\wsl.exe This has fixed the problem in my case. Please let me know how it works for you.

And it works well for me!

It‘s the best way to solve this!!! It’s works! Even don’t need a reboot! Thank you !

I don’t think it makes any sense to keep reporting the bug is still not fixed, because there hasn’t been any claim from Microsoft that it’s fixed. It’s pretty obvious that the issue is universal and easily reproducible, and it’s very likely that Microsoft is already aware of it. So such comments only spam this issue and and the email inbox of those who have subscribed to this issue.

2021 年了,这个问题还没解决,不愧是你,微软

22年了(update)

Instead of C:\windows\system32\wsl.exe, the new path is under windows apps, which for me is C:\Program Files\WindowsApps\MicrosoftCorporationII.WindowsSubsystemForLinux_1.0.0.0_x64__8wekyb3d8bbwe\wsl.exe (you can find the path by Everything or Task Manager). You may also need to add wslservice.exe.

(I am not sure all of these are needed. I just add all paths I found in task manager)

# version 2.0.4
NoLsp.exe "C:\Program Files\WindowsApps\MicrosoftCorporationII.WindowsSubsystemForLinux_2.0.4.0_x64__8wekyb3d8bbwe\wsl.exe"

# some new path in 2.0.4
NoLsp.exe "C:\Program Files\WSL\wsl.exe"
NoLsp.exe "C:\Program Files\WSL\wslservice.exe"
NoLsp.exe "C:\Program Files\WSL\wslhost.exe"
NoLsp.exe "C:\Program Files\WSL\wslrelay.exe"

# some old path found in task manager
NoLsp.exe "C:\Windows\System32\wsl.exe"

If you don’t want to reboot, use taskkill -IM "wslservice.exe" /F to kill all wsl stuff.

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\WinSock2\Parameters\AppId_Catalog\04C4CA21]
"AppFullPath"="C:\\Program Files\\WindowsApps\\MicrosoftCorporationII.WindowsSubsystemForLinux_1.0.0.0_x64__8wekyb3d8bbwe\\wsl.exe"
"PermittedLspCategories"=dword:80000000

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\WinSock2\Parameters\AppId_Catalog\0E1558B0]
"AppFullPath"="C:\\Program Files\\WindowsApps\\MicrosoftCorporationII.WindowsSubsystemForLinux_1.0.0.0_x64__8wekyb3d8bbwe\\wslservice.exe"
"PermittedLspCategories"=dword:80000000

Looks like this magic registry stuff keeps WSL2/winsock combo happy, for at least three of us at work so far.

Disclaimer: works fine for me with no apparent side-effects, but I don’t entirely know what it’s doing. Use at your own risk…

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\WinSock2\Parameters\AppId_Catalog\0408F7A3] "AppFullPath"="C:\\\\windows\\\\system32\\\\wsl.exe" "PermittedLspCategories"=dword:80000000

The problem is still not fixed. I need to reset the winsock everytime. winver: 19041.113

  1. Create one file named wsl2.reg (or any other filename with .reg suffix)
  2. Open this file in notepad.exe, pase text below to it.
  3. Save file.
  4. Double click this file, give it Administrator permission
  5. Open wsl.exe

wsl2.reg code, I copied from this issue

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\WinSock2\Parameters\AppId_Catalog\0408F7A3]
"AppFullPath"="C:\\\\windows\\\\system32\\\\wsl.exe"
"PermittedLspCategories"=dword:80000000

Or you can download my wsl2.reg directly:

https://baijifeilong.github.io/wsl2.reg

As many other winsock modules breaks wsl2, I think it is not Proxifier’s fault. It is likely that the communication between wsl2 and other components (likely hyperv?) is broken.

I captured events from wsl.exe using procmon when reproducing the issue Logfile.zip

And there are the windows event logs (system) wsl4177.evtx.zip

So the problem is, after using any kinds of vpn (such as shadowsocks or whatever), wsl2 will crash when users try to start it. So I think it needs to be compatible with vpns in the future.

not work on win11 22H2

如果应用商店安装了Windows Subsystem for Linux

  1. 首先找到安装位置,最简单的方法是,打开应用商店,找到应用Windows Subsystem for Linux,点击应用详细介绍页面的打开按钮,会新打开一个terminal窗口,窗口的标题上面有所安装的wsl.exe的全路径。

    或者也可以手动搜索,由于目录C:\Program Files\WindowsApps是保护文件夹,没法直接在资源管理器中搜索,可以管理员打开powershell

    cd "C:\Program Files\WindowsApps"
    ls
    

    找到对应版本的wsl目录,例如MicrosoftCorporationII.WindowsSubsystemForLinux_1.1.2.0_x64__8wekyb3d8bbwe

  2. 下载nolsp.exe

  3. 管理员打开powershell,执行以下命令:

    # 打开nolsp.exe所在目录
    cd E:\Downloads\Other\nolsp.exe
    
    # 该步骤就相当于添加注册表
    .\nolsp.exe "C:\Program Files\WindowsApps\MicrosoftCorporationII.WindowsSubsystemForLinux_1.1.2.0_x64__8wekyb3d8bbwe\wsl.exe"
    .\nolsp.exe "C:\Program Files\WindowsApps\MicrosoftCorporationII.WindowsSubsystemForLinux_1.1.2.0_x64__8wekyb3d8bbwe\wslservice.exe"
    # 注意:这里的wsl.exe以及wslservice.exe,必须是全路径,不能是相对路径。
    

    打开注册表regedit,找到\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\WinSock2\Parameters\AppId_Catalog,依次点击此目录的各项,可以找到两项:

    [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\WinSock2\Parameters\AppId_Catalog\2BB0D7FB]
    "AppFullPath"="C:\Program Files\WindowsApps\MicrosoftCorporationII.WindowsSubsystemForLinux_1.1.2.0_x64__8wekyb3d8bbwe\wsl.exe"
    "PermittedLspCategories"=dword:80000000
    
    [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\WinSock2\Parameters\AppId_Catalog\2FB92E99]
    "AppFullPath"="C:\Program Files\WindowsApps\MicrosoftCorporationII.WindowsSubsystemForLinux_1.1.2.0_x64__8wekyb3d8bbwe\wslservice.exe"
    "PermittedLspCategories"=dword:80000000
    

至此,就可以打开wsl了。
如果商店更新了Windows Subsystem for Linux,需要重新执行一遍此流程


如果应用商店没有安装了Windows Subsystem for Linux

直接在注册表regedit添加项即可:

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\WinSock2\Parameters\AppId_Catalog\0408F7A3]
"AppFullPath"="C:\Windows\System32\wsl.exe"
"PermittedLspCategories"=dword:80000000

临时解决办法:

管理员打开powershell,运行netsh winsock reset,不用重启,就可以打开wsl了。
但是每次重新启动电脑时,都要重新运行一次此流程。

Same issue and it solves with the winsock reset. This is another proof that Microsoft is a noob in writing proper software. “In computing, the Windows Sockets API, later shortened to Winsock, is a technical specification that defines how Windows network software should access network services, especially TCP/IP.” A linux shell should run without using tcp/ip communication.

windows10 19041.21,this problem is still not fixed。

@Librazy - Thanks for the additional logs. Unfortunately as I mentioned before, wsl.exe is not where the errors are coming from. I suspect proxifier and other winsock modules are not correctly handling the Hyper-V socket address family (AF_HYPERV). I would strongly suggest reporting the issue to them.

My computer updated to WSL 2.0.9.0 today and this broke again. I had previously set up the Powershell script mentioned in https://github.com/microsoft/WSL/issues/4177#issuecomment-1359200646 but that wasn’t fixing it this time. I had to use NoLsp.exe again and run the following commands to get it working again:

taskkill -IM "wslservice.exe" /F
NoLsp.exe "C:\Program Files\WSL\wsl.exe"
NoLsp.exe "C:\Program Files\WSL\wslservice.exe"
NoLsp.exe "C:\Program Files\WindowsApps\MicrosoftCorporationII.WindowsSubsystemForLinux_2.0.9.0_x64__8wekyb3d8bbwe\wsl.exe"

For the people using Proxifier like me and if you don’t want to do weird stuff on your register,

I had a response from the support of Proxifier, and they responded that their new version still in beta support wsl 2,

I had no issue with my Docker on wsl 2, or on my ubuntu,

www.proxifier.com/beta

When I run this command netsh winsock reset and restart my PC, it can be resolved temporarily. But next time when I use WSL, it doesn’t work for me. The problem still had happend.

still 18956

The problem exists on build 18950.1000. update: 18956.1000, still here

heroes who are digging to this issue, let me summarize the problem for you:

  • if you’re having issue launching docker, or wsl, AND you’re using proxy app the same time, you may encounter this problem, the wsl won’t launch.
  • this is probably your proxy app is using lsp to take control of wsl network automatically for convenience(my guess), which is deprecated already since windows 8, but wsl does not support this, and it will not be fixed, so we’re having this issue for years.
  • one recommended work-around is to use @mariotaku 's script to add wsl entry to your registry.
  • run the exe as admin is not recommended, an anonymous exe should not be trusted for security concern.

but if you’re curious about how the appid catagory hash is decided (as i do), here’s a demo to show how the hash is calculated,so you can write code to do the job for yourself, completely independent to ws2_32.dll, here’s some note for the demo:

  • the path is using wide char.
  • the drive letter is ignored.
  • path capitalized during hash calculation
  • L'\0' should not be calculated, if you’re using c string.

case close, studied this for a week.

Developers of Proxifier told me the reason and gave me a solution.

Thanks for the info. We have reproduced this issue. Apparently, wsl.exe displays this error if Winsock LSP DLL gets loaded into its process. The easiest solution is to use WSCSetApplicationCategory WinAPI call for wsl.exe to prevent this. Under the hood the call creates an entry for wsl.exe at HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\WinSock2\Parameters\AppId_Catalog This tells Windows not to load LSP DLLs into wsl.exe process. We have a tool that can make this call: www.proxifier.com/tmp/Test20200228/NoLsp.exe Please just run as admin with the full path to wsl.exe as the parameter: NoLsp.exe c:\windows\system32\wsl.exe This has fixed the problem in my case. Please let me know how it works for you.

And it works well for me!

After following the prompts, an error will still be reported

image

image

Developers of Proxifier told me the reason and gave me a solution.

Thanks for the info. We have reproduced this issue. Apparently, wsl.exe displays this error if Winsock LSP DLL gets loaded into its process. The easiest solution is to use WSCSetApplicationCategory WinAPI call for wsl.exe to prevent this. Under the hood the call creates an entry for wsl.exe at HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\WinSock2\Parameters\AppId_Catalog This tells Windows not to load LSP DLLs into wsl.exe process. We have a tool that can make this call: www.proxifier.com/tmp/Test20200228/NoLsp.exe Please just run as admin with the full path to wsl.exe as the parameter: NoLsp.exe c:\windows\system32\wsl.exe This has fixed the problem in my case. Please let me know how it works for you.

And it works well for me!

Open poweshel as admin and run .\NoLsp.exe c:\windows\system32\wsl.exe

Proxifier and WSL (Ubuntu 18.04) working at same time, thanks

windows10 18956.1000,this problem is still not fixed。

Still reproducible on recent insider versions

@RichardDavies Thank you, worked for me. I have used @mariotaku script successfully until now, but i also needed to execute NoLsp.exe.

Here is a adjusted script, that first executes the NoLsp.exe and afterwards the registry fix:

#Requires -RunAsAdministrator
# Fix for https://github.com/microsoft/WSL/issues/4177

$MethodDefinition = @'
[DllImport("ws2_32.dll", CharSet = CharSet.Unicode)]
public static extern int WSCSetApplicationCategory([MarshalAs(UnmanagedType.LPWStr)] string Path, uint PathLength, [MarshalAs(UnmanagedType.LPWStr)] string Extra, uint ExtraLength, uint PermittedLspCategories, out uint pPrevPermLspCat, out int lpErrno);
'@

$Ws2Spi = Add-Type -MemberDefinition $MethodDefinition -Name 'Ws2Spi' -PassThru

$WslLocation = Get-AppxPackage MicrosoftCorporationII.WindowsSubsystemForLinux | Select-Object -expand InstallLocation

# Specify paths to all wsl locations

#since WSL Version 2.X.Y.Z also neccessary to execute fix in the "Program Files" locations https://github.com/microsoft/WSL/issues/4177#issuecomment-1817216126
$WslLocations = @(
    (Get-AppxPackage MicrosoftCorporationII.WindowsSubsystemForLinux | ForEach-Object { $_.InstallLocation }),
    "C:\Program Files\WSL"
)

$Executables = ("wsl.exe", "wslservice.exe", "wslg.exe", "wslhost.exe");

foreach ($WslLocation in $WslLocations) {
	
    Write-Output "Looping trough path:  $WslLocation";
    Write-Output "==========================================";
	
    foreach ($Exe in $Executables) {
        $ExePath = Join-Path $WslLocation $Exe
		
	# Test if exe exists in the path (not all exe's are in all locations)
	if (-not (Test-Path $ExePath -PathType Leaf)) {
		Write-Output "Path not found:  $ExePath!";
		continue;
	}
				
	# First execute NoLsp.exe fix
        & ".\NoLsp.exe" $ExePath
		
	# Second execute registry fix
	$ExePathLength = $ExePath.Length;
        $PrevCat = $null;
        $ErrNo = $null;
		
        if ($Ws2Spi::WSCSetApplicationCategory($ExePath, $ExePathLength, $null, 0, [uint32]"0x80000000", [ref] $PrevCat, [ref] $ErrNo) -eq 0) {
            Write-Output "Added $ExePath!";
        }
    }
    Write-Output "";
}

I’m running this script as suggested above with highest priviliges via the Task Scheduler on every startup. The NoLsp.exe needs to be in the same folder as this script.

Tested with WSL 2 v2.0.9.0 and ProxyCap 5.38

I have 2 company computers. Only one has trouble with WSL. So far as I know, computers are same Windows 10 image. When I try to run wsl, the “bad” computer says

The attempted operation is not supported for the type of object referenced.
Press any key to continue...

If I have an administrator around, they can open PowerShell and run

netsh winsock reset

That solves the problem until the system is forced to reset.

I want to understand why the problem only affects one computer. Both of them have Cisco VPN, but the problem happens whether or not I’m connected to VPN. The versions of Cisco AnyConnect Secure Mobility Client are slightly different, thought. The trouble computer has Cisco 4.9.05042.

I don’t have a web proxy, that I know of, but if you tell me what to look for, I can try. I don’t have admin authority, hence, I’m totally stuck!

It is possible that the corporate IT applied slightly different security policies on the 2 computers. On the new one, but not the old, I could not get the Ubuntu apps to display onto X11 server without a battle with the firewall. We had to open up both the public and private channels for X410 and Vcxrv to get to the desktop.

Can you help me understand if I have same winsock problem and what program is causing it?

Thanks, this command netsh winsock reset also solves docker/for-win#7208 and docker/for-win#7919

I have 2 company computers. Only one has trouble with WSL. So far as I know, computers are same Windows 10 image. When I try to run wsl, the “bad” computer says

The attempted operation is not supported for the type of object referenced.
Press any key to continue...

If I have an administrator around, they can open PowerShell and run

netsh winsock reset

That solves the problem until the system is forced to reset.

I want to understand why the problem only affects one computer. Both of them have Cisco VPN, but the problem happens whether or not I’m connected to VPN. The versions of Cisco AnyConnect Secure Mobility Client are slightly different, thought. The trouble computer has Cisco 4.9.05042.

I don’t have a web proxy, that I know of, but if you tell me what to look for, I can try. I don’t have admin authority, hence, I’m totally stuck!

It is possible that the corporate IT applied slightly different security policies on the 2 computers. On the new one, but not the old, I could not get the Ubuntu apps to display onto X11 server without a battle with the firewall. We had to open up both the public and private channels for X410 and Vcxrv to get to the desktop.

Can you help me understand if I have same winsock problem and what program is causing it?

Developers of Proxifier told me the reason and gave me a solution.

Thanks for the info. We have reproduced this issue. Apparently, wsl.exe displays this error if Winsock LSP DLL gets loaded into its process. The easiest solution is to use WSCSetApplicationCategory WinAPI call for wsl.exe to prevent this. Under the hood the call creates an entry for wsl.exe at HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\WinSock2\Parameters\AppId_Catalog This tells Windows not to load LSP DLLs into wsl.exe process. We have a tool that can make this call: www.proxifier.com/tmp/Test20200228/NoLsp.exe Please just run as admin with the full path to wsl.exe as the parameter: NoLsp.exe c:\windows\system32\wsl.exe This has fixed the problem in my case. Please let me know how it works for you.

And it works well for me!

@1160300208 Thanks you! It works for me (19564.1005).

S'all good, man

windows 10 19041.113, this problem is still not fixed, hope it can be fixed.

reproducible in 18963

Still relevant. 10.0.18945.1001

xiaoqidun_2019-07-23_10-12-16 windows10 18941.1001,this problem is still not fixed。

@craigloewen-msft @OneBlue Hey guys I saw the AMA and your help to fix the issue https://github.com/microsoft/WSL/issues/10812. So i hope you might also help us here out 😄.

The summary of this issue (iirc): It seems that some proxy tools (like proxifier or proxycap) interfere with the socket communication between the wsl instance and the host. The solution for this was at the begining to “deactivate”/“unload” a DLL called “Lsp” from the wsl.exe. For that, proxifier has build a small tool called NoLsp.exe, which did this “unloading” of the lsp dll.

Then the changed happened, that wsl gets automatically updated from the windows store. After this, I had to execute the NoLsp.exe fix after every update (because every update had a new wsl.exe in an other path) AND additionaly also had to do some registry fix.

To somehow automate this fixes, i’ve used successfully @mariotaku script (https://github.com/microsoft/WSL/issues/4177#issuecomment-1359200646) and adjusted it, so that also the NoLsp.exe fix was executed. This worked for me since January 2023 until now til WSL v1.2.5.

Since the last WSL Update (2.0.X.Y) i also had to execute the fix at the wsl.exe, that’s in “Program Files” Folder, in addition to the Microsoft Store Location. (The script automaticaly find’s the path to the wsl.exe’s that are updated by the Microsoft Store). Here is the complete script : https://github.com/microsoft/WSL/issues/4177#issuecomment-1822438206

Now everything is working again fine. I can’t find any more the official link to the NoLsp.exe, but here is the one from the wayback machine: https://web.archive.org/web/20220728095911/http://www.proxifier.com/tmp/Test20200228/NoLsp.exe I think the NoLsp.exe does only a registry entry, to unload the dll and therefore this fix could also be done without the .exe (Maybe somone can post the manual registry fix).

My complete setup is :

  • ProxyCap 5.38
  • Citrix Secure Acces 22.10.1.9 (for VPN)
  • WSL vpn-kit (without it, i don’t have internet acces inside the wsl instance)

tldr: Would it be possible to remove this Lsp DLL from WSL AND also implement the second registry fix in an upcoming WSL Update ? I don’t know for what this DLL is, but everything is working fine without it. Or make it an wsl config, so that we need to opt in for this fix.

Thanks in advance for your help !

P.S. the new wsl config options (networkingMode, dnsTunneling etc.) didn’t helped for this problem. The problem lies in the proxy tools, that they interferece the socket communication and can be fixed by the lsp fix

How I managed to solve the problem:

> cd "C:\Program Files\WindowsApps\"

Search for some folder that looks like "MicrosoftCorporationII.WindowsSubsystemForLinux ... x64 ...". For me, it was "C:\Program Files\WindowsApps\MicrosoftCorporationII.WindowsSubsystemForLinux_1.0.0.0_x64__8wekyb3d8bbwe"

Go in and list its files. It should contain "wsl.exe" and "wslservice.exe".

Download https://web.archive.org/web/20220728095911/http://www.proxifier.com/tmp/Test20200228/NoLsp.exe

Open a windows terminal with admin priviledge.

Kill WSL with
> taskkill -IM "wslservice.exe" /F

Run NoLsp.exe on both "wsl.exe" and "wslservice.exe". For me, it was like
> .\NoLsp.exe "C:\Program Files\WindowsApps\MicrosoftCorporationII.WindowsSubsystemForLinux_1.0.0.0_x64__8wekyb3d8bbwe\wsl.exe"

> .\NoLsp.exe "C:\Program Files\WindowsApps\MicrosoftCorporationII.WindowsSubsystemForLinux_1.0.0.0_x64__8wekyb3d8bbwe\wslservice.exe"
  1. 创建一个名为wsl2.reg(或任何其他带有 .reg 后缀的文件名)的文件
  2. 在 中打开此文件notepad.exe,将下面的文本粘贴到其中。
  3. 保存存档。
  4. 双击这个文件,给它Administrator权限
  5. 打开wsl.exe

wsl2.reg 代码,我从这个问题复制

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\WinSock2\Parameters\AppId_Catalog\0408F7A3]
"AppFullPath"="C:\\\\windows\\\\system32\\\\wsl.exe"
"PermittedLspCategories"=dword:80000000

或者你可以wsl2.reg直接下载我的:

https://baijifeilong.github.io/wsl2.reg

解决了,感谢

19008.1 the problem is still not fixed it occured when i use v2ray

Can confirm ProxyCap is now working with WSL 2.1.0 without any fixes. This is great, thank you very much !!!

如果应用商店安装了Windows Subsystem for Linux

  1. 首先找到安装位置,最简单的方法是,打开应用商店,找到应用Windows Subsystem for Linux,点击应用详细介绍页面的打开按钮,会新打开一个terminal窗口,窗口的标题上面有所安装的wsl.exe的全路径。

    或者也可以手动搜索,由于目录C:\Program Files\WindowsApps是保护文件夹,没法直接在资源管理器中搜索,可以管理员打开powershell

    cd "C:\Program Files\WindowsApps"
    ls
    

    找到对应版本的wsl目录,例如MicrosoftCorporationII.WindowsSubsystemForLinux_1.1.2.0_x64__8wekyb3d8bbwe

  2. 下载nolsp.exe

  3. 管理员打开powershell,执行以下命令:

    # 打开nolsp.exe所在目录
    cd E:\Downloads\Other\nolsp.exe
    
    # 该步骤就相当于添加注册表
    .\nolsp.exe "C:\Program Files\WindowsApps\MicrosoftCorporationII.WindowsSubsystemForLinux_1.1.2.0_x64__8wekyb3d8bbwe\wsl.exe"
    .\nolsp.exe "C:\Program Files\WindowsApps\MicrosoftCorporationII.WindowsSubsystemForLinux_1.1.2.0_x64__8wekyb3d8bbwe\wslservice.exe"
    # 注意:这里的wsl.exe以及wslservice.exe,必须是全路径,不能是相对路径。
    

    打开注册表regedit,找到\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\WinSock2\Parameters\AppId_Catalog,依次点击此目录的各项,可以找到两项:

    [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\WinSock2\Parameters\AppId_Catalog\2BB0D7FB]
    "AppFullPath"="C:\Program Files\WindowsApps\MicrosoftCorporationII.WindowsSubsystemForLinux_1.1.2.0_x64__8wekyb3d8bbwe\wsl.exe"
    "PermittedLspCategories"=dword:80000000
    
    [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\WinSock2\Parameters\AppId_Catalog\2FB92E99]
    "AppFullPath"="C:\Program Files\WindowsApps\MicrosoftCorporationII.WindowsSubsystemForLinux_1.1.2.0_x64__8wekyb3d8bbwe\wslservice.exe"
    "PermittedLspCategories"=dword:80000000
    

至此,就可以打开wsl了。 如果商店更新了Windows Subsystem for Linux,需要重新执行一遍此流程

如果应用商店没有安装了Windows Subsystem for Linux

直接在注册表regedit添加项即可:

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\WinSock2\Parameters\AppId_Catalog\0408F7A3]
"AppFullPath"="C:\Windows\System32\wsl.exe"
"PermittedLspCategories"=dword:80000000

临时解决办法:

管理员打开powershell,运行netsh winsock reset,不用重启,就可以打开wsl了。 但是每次重新启动电脑时,都要重新运行一次此流程。

This workaround must be applied every time after the wsl app (app store version) updated, since the versioned path keeps changing. But it’s hard to tell when or even whether the app was updated. So … still quite a mess.

!! proxifier 4.x version will not confilct with wsl2.

Developers of Proxifier told me the reason and gave me a solution.

Thanks for the info. We have reproduced this issue. Apparently, wsl.exe displays this error if Winsock LSP DLL gets loaded into its process. The easiest solution is to use WSCSetApplicationCategory WinAPI call for wsl.exe to prevent this. Under the hood the call creates an entry for wsl.exe at HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\WinSock2\Parameters\AppId_Catalog This tells Windows not to load LSP DLLs into wsl.exe process. We have a tool that can make this call: www.proxifier.com/tmp/Test20200228/NoLsp.exe Please just run as admin with the full path to wsl.exe as the parameter: NoLsp.exe c:\windows\system32\wsl.exe This has fixed the problem in my case. Please let me know how it works for you.

And it works well for me!

This works to start WSL, but because of the winsock shutdown, it won’t connect to the internet. local network works fine. Need to do netsh winsock reset

As per @Mehdi13k8 comment, after installing the Proxifier v4.01 Beta 2, WSL 2 works as expected.

I’m also using a VPN (Citrix Secure Access).

And now with the automatic enablement auf DNS tunneling in 2.1.0, i now don’t have internet/intranet access inside the wsl. The fix for me is now to disable that via the .wslconfig file, e.g.

[wsl2]
dnsTunneling=false

And internet/intranet access works again.

P.S. i need to use the wsl-vpnkit for that. In theory dnsTunneling and networkMode=mirrored should do the trick, but sadly it doesn’t work. But maybe this is a specifc issue with the Citrix Secure Access Client.

@mariotaku Out of curiosity, how do you run this script as an Administrator on boot up?

When I add it to the task scheduler, I configured it to use the highest privilege.

The store version path of wsl.exe and wslservice.exe changes every version WSL released on store, so I have to manually add registry entries and reboot my computer every time WSL updated, to make WSL2 and my VPN client works together.

For 1.0.3.0:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\WinSock2\Parameters\AppId_Catalog\04FC3F2F]
"AppFullPath"="C:\\Program Files\\WindowsApps\\MicrosoftCorporationII.WindowsSubsystemForLinux_1.0.3.0_x64__8wekyb3d8bbwe\\wsl.exe"
"PermittedLspCategories"=dword:80000000

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\WinSock2\Parameters\AppId_Catalog\12AF910F]
"AppFullPath"="C:\\Program Files\\WindowsApps\\MicrosoftCorporationII.WindowsSubsystemForLinux_1.0.3.0_x64__8wekyb3d8bbwe\\wslservice.exe"
"PermittedLspCategories"=dword:80000000

又不能用了,不亏是你,微软

这个问题有啥前人的研究思路吗?每天都在winsock reset有点受不了,想抽空看看能不能自己尝试解决一下

WSL2 wont start if I have Sangfor EasyConnect connected. I have to run netsh winsock reset after vpn start to use wsl.exe. Adding reg key does not resolve the issue.

in 19018.1 it’s still there. I can start wsl only after reseting winsock using powershell with administrative privilege. And I noticed that an opened wsl.exe won’t crash after starting use vpn.

If you’re still seeing this error, could you help us diagnose it by collecting networking logs?

Instructions on how to do so are here. Thanks!

I took a look at the trace and I’m not seeing any relevant events in the service etl. If possible could you do the following?

wsl.exe --shutdown start trace launch distribution stop trace