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 withThe 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.
-
Strace of the failing command, if applicable: N/A
-
For WSL launch issues, please collect detailed logs.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 34
- Comments: 95 (8 by maintainers)
Links to this issue
Commits related to this issue
- chore(wsl): update wsl min version to 2.3.24 In versions before WSL@2.1.0, there were compatibility issues with Winsock, which could lead to WSL not functioning properly. For more information, see: h... — committed to BlackHole1/ovm-win by BlackHole1 2 years ago
- chore(wsl): update wsl min version to 2.3.24 (#100) In versions before WSL@2.1.0, there were compatibility issues with Winsock, which could lead to WSL not functioning properly. For more information,... — committed to oomol-lab/ovm-win by BlackHole1 2 years ago
Developers of Proxifier told me the reason and gave me a solution.
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.
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.
Works for me, steps:
.\NoLsp.exe c:\windows\system32\wsl.exeThen you well see return:Success!I encounter this problem and use this method to solve. But my proxifier can’t be used.
There are some caveats for NoLsp.exe.
So I created this script to run on boot. I have tested and now it works without issue. (Please remember to kill
wslservice.exeif it doesn’t work)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.
22年了(update)
Instead of
C:\windows\system32\wsl.exe, the new path is under windows apps, which for me isC:\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 addwslservice.exe.(I am not sure all of these are needed. I just add all paths I found in task manager)
If you don’t want to reboot, use
taskkill -IM "wslservice.exe" /Fto kill all wsl stuff.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:80000000The problem is still not fixed. I need to reset the winsock everytime. winver: 19041.113
wsl2.reg(or any other filename with .reg suffix)notepad.exe, pase text below to it.Administratorpermissionwsl2.reg code, I copied from this issue
Or you can download my
wsl2.regdirectly: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首先找到安装位置,最简单的方法是,打开应用商店,找到应用
Windows Subsystem for Linux,点击应用详细介绍页面的打开按钮,会新打开一个terminal窗口,窗口的标题上面有所安装的wsl.exe的全路径。下载nolsp.exe
管理员打开
powershell,执行以下命令:打开注册表
regedit,找到\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\WinSock2\Parameters\AppId_Catalog,依次点击此目录的各项,可以找到两项:至此,就可以打开wsl了。
如果商店更新了
Windows Subsystem for Linux,需要重新执行一遍此流程如果应用商店没有安装了
Windows Subsystem for Linux直接在注册表
regedit添加项即可:临时解决办法:
管理员打开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.
Fixed with https://github.com/microsoft/WSL/releases/tag/2.1.0
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:
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 resetandrestartmy 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:
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:
L'\0'should not be calculated, if you’re using c string.case close, studied this for a week.
After following the prompts, an error will still be reported
Open poweshel as admin and run
.\NoLsp.exe c:\windows\system32\wsl.exeProxifier 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:
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
Thanks, this command
netsh winsock resetalso solves docker/for-win#7208 and docker/for-win#7919I 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
If I have an administrator around, they can open PowerShell and run
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?
@1160300208 Thanks you! It works for me (19564.1005).
windows 10 19041.113, this problem is still not fixed, hope it can be fixed.
reproducible in 18963
Still relevant. 10.0.18945.1001
@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 :
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:
解决了,感谢
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 !!!
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.
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 resetAs 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.
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.
When I add it to the task scheduler, I configured it to use the highest privilege.
The store version path of
wsl.exeandwslservice.exechanges 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:
这个问题有啥前人的研究思路吗?每天都在winsock reset有点受不了,想抽空看看能不能自己尝试解决一下
WSL2 wont start if I have Sangfor EasyConnect connected. I have to run
netsh winsock resetafter vpn start to usewsl.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