Open choung opened 4 years ago
I suppose this is also the reason why my WSL 2 Emacs over Xming X11 windows server have aborted with a traceback every time the computer returns from sleep.
Similarly here, I suppose this is the cause of issue I experience with IntelliJ IDEA run from WSL 2, connecting to X Server on Windows. After coming back from sleep, IntelliJ window is gone and I have to start it again. Unfortunately IntelliJ IDEA doesn't (yet?) support WSL for Java development, that's why I run it straight from WSL (https://intellij-support.jetbrains.com/hc/en-us/community/posts/360004275400-Developing-in-Windows-Subsystem-for-Linux and https://youtrack.jetbrains.com/issue/IDEA-223986)
I'm getting this as well, but I use hibernate. I'm on Version 10.0.20197.1000
It's annoying, things I did to no avail:
restarting via WSL --shutdown does nothing (same as restarting Lxssmanager).
I have to reboot just to get connectivity back. Is there a way to initialize WSL's network stack since IP is
Same on insider 20180.1000 (wsl kernel: 4.19.121), must reboot windows to get network back
@thisguychris :
I have to reboot just to get connectivity back.
and @david50407 :
must reboot windows to get network back
This seems to be a different issue than the one reported by @klesniewski :
IntelliJ IDEA run from WSL 2, connecting to X Server on Windows. After coming back from sleep, IntelliJ window is gone and I have to start it again.
which is what I am experiencing as well: I'm running an X server on Windows (VcXsrv) to use graphical Linux applications. This works perfectly, except that when Windows goes into standby and wakes up again, all X windows are gone. The Linux applications don't report any error (in the console) and appear to be running fine; it's only the X output that is gone (thus rendering the apps unuseable). I can simply kill the apps and restart them, and the X windows reappear fine. No reboot required, which is why I think there are separate issues here.
@Spaak I was speaking at the context of the OP, which was @choung.
If this is a new issue, should I file a new one? To add, I also use an X Server. But on my end, I really need to restart Windows. Not even signout works. I really need to restart the OS to connectivity back.
cc @therealkenc
same problem here. for me changing the network or disconnecting and connecting apart from the above also causes the same issue. reboot is the only fix
changing nameservers and using wsl --shutdown does not work
OS: Windows Insider Dev Build - 20197.1000
My laptop used to work fine when closing and opening the lid. Now, it requires a reboot to reconnect. wsl --shutdown
didn't work either.
OS: Windows Insider Dev Build - Version 2004 - Build 20201.1000
Same problem.
After sleeping mode, I lost the internet connection for wsl2.
Only reboot can solve the problem, wsl --shutdown
cannot solve. Still looking for / waiting better solution!
OS: Win10 pro insider preview: build 20201.re_prerelease.200822-1922
wsl cat /proc/version
:
Linux version 4.19.128-microsoft-standard (oe-user@oe-host) (gcc version 8.2.0 (GCC)) #1 SMP Tue Jun 23 12:58:10 UTC 2020
Did anyone manged to resolve this issue?
I realized WSL Connection type
in Hyper-V Virtual Switch Manager change from Internal network
to Private network
after this. By restarting the system, this sets back to Internal network
automatically.
I have the same issue, insider OS build 20206.1000
Similar issue here. It seems heavily linked with Hyper-V and stops obeying to any sort of logic once the issue starts to happen, reboot solves it. The problem occurs since the update to Windows 10 2004. Latest KB doesn't seem to resolve the issue.
Also the same issue here. I use GUI apps through an X server and this issue is highly impacting.
I do not require a reboot for things to work again, restarting the app suffices. (emacs through X410 X server).
@Soberia this solution is only works once. I use this fix to get my network back and sleep again then the fix won't work anymore until I reboot...
Still going on here as well.
For me is gone after updating to Windows Insider 20236
OK so on build 20231 the wsl --shutdown
works for me.
I have the same issue - very annoying.
Only reboot makes WSL2 working again. I have not seen the issue when being in the office (no VPN involved)
I have the same issue.
I can't connect to my WSL2 ubuntu after returning from sleep mode. VS Code connection is lost after waking up and can't reconnect unless I reboot my pc. Also, I can't connect with Windows Terminal application.
I used x11-over-vsock to solve the problem that the link between wsl2 and x410 is broken after the network change, but there is a problem with this library that the cpu will soar when the window is moved. I hope wsl2 can support vsock as soon as possible
+1 it's annoying, my emacs x11 window keep closing. I just turned off sleep :(
@gradinarot
For me is gone after updating to Windows Insider 20236
Really? For WSL2 - not WSL1! Could you really reproduce this?
Which channel of windows insider program are you using?
Yes, im using wsl2. But now I have a problem with some connections. For example doing a git pull will fail 20% of the time. This thing happenz for all ssl connections
@gradinarot
For me is gone after updating to Windows Insider 20236
Really? For WSL2 - not WSL1! Could you really reproduce this?
Which channel of windows insider program are you using?
Folks at WSL are working on native GUI - https://devblogs.microsoft.com/commandline/whats-new-in-the-windows-subsystem-for-linux-september-2020/#gui-apps and you can already check it out in Insiders build (not sure which version though).
@troglotit not available yet in dev channel (21277), so I think that doesn't released into all insiders yet.
@choung
The following problem only happens when TCP connections are made from WSL2 to Windows. When connections are made from Windows to WSL2, they are restored after sleep mode as expected.
How about the following method? The point is the R option of ssh.
Execute the following on WSL2.
$ sudo apt install openssh-server # if necessary
$ sudo ssh-keygen -A # if necessary
$ sudo service ssh start
Start OpenSSH Authentication Agent service on Windows.
Execute the following on Windows.
> ssh-keygen.exe -t ed25519
> ssh-add.exe %USERPROFILE%\.ssh\id_ed25519
Execute the following on WSL2.
$ cd
$ mkdir .ssh # if necessary
$ chmod 700 .ssh # if necessary
$ cd .ssh
$ cat /mnt/c/Users/<Windows user>/.ssh/id_ed25519.pub >> authorized_keys
$ chmod 600 authorized_keys
Add the following to .bash_profile.
if ! service ssh status > /dev/null 2>&1; then
wsl.exe -d "$WSL_DISTRO_NAME" -u root service ssh start
fi
if ! ss -lt4 | grep -q '127.0.0.1:6020'; then setsid ssh.exe -f -N -R 6020:127.0.0.1:6000 $USER@localhost & fi
[ -r ~/.bashrc ] && source ~/.bashrc
6. Add the following to .bashrc.
export DISPLAY=:20
7. Restart WSL2.
@smzht that's an interesting idea. Not really liking the idea of sending x traffic through ssh though! It's a good idea for other use cases perhaps.
@robmwalsh Ssh has an X option. It ’s similar to that.
@smzht worth a try I suppose. My computer would certainly appreciate being able to go to sleep again, even if it does have to encrypt display traffic that's not even leaving my computer!
Related: Is anybody from Microsoft actually working on this?
This problem has gone away after I updated my Ubuntu by doing the following:
sudo apt update && sudo apt upgrade
.
I wrote a short article on how I solve this problem: WSL2 slowing down over time issue: Medium
Same problem here. Watching to see if this problem gets solved...
Same here. Upgraded to WSL2 and now things are not coming back after sleep. Using Void Linux and X410
I recently discovered https://github.com/nbdd0121/wsld which provides a workaround based on vsocks. So far it works really well for my X forwarding use case.
https://github.com/nbdd0121/wsld does seem to work! I had to download pre-built binary for windows because custom built executable would just insta-crash. I am running x410/Void/i3 so I had to put the snippet from wsld into .profile and set up windows daemon in task scheduler.
I recently discovered https://github.com/nbdd0121/wsld which provides a workaround based on vsocks. So far it works really well for my X forwarding use case.
I also confirm that the wsld
indeed works perfectly. The gui app has persisted for several days
Could not use wsld (os error 10013) in any way sadly.
Hmm, today my computer with Windows 19042.928 came back from sleep with my X11 Emacs still running. Good! What changed?
Or maybe I should wait a bit and see if it wasn't just a one-time thing...
Same here on Version 1909 18363.1500
. It just seems to work now. 🤷
I'm experiencing this same issue with Windows 11 22000.282 and WSL2 Ubuntu 20.04. Network works fine on fresh boot, but after resuming from sleep or hibernate, WSL network connection is broken.
Restarting LxssManager service on Windows terminated WSL distro
Check in your /etc
folder for resolv.conf
and wsl.conf
. If resolv.conf
is missing you will get DNS resolution issues.
So check what is in your wsl.conf
, assuming that you have one ...
If it contains:
[network]
generateResolvConf = false
Then WSL is not going to regenerate the resolv.conf
for you and you have to create/edit your own (e.g. sudo nano /etc/resolv.conf
and make sure it is pointing at some nameservers.
The default for generateResolvConf
is supposed to be true
(from what I understand), but sometimes that doesn't seem to be correct ...
So you can explicitly set generateResolvConf = true
in the /etc/wsl.conf
, and then reboot (yep), to get it to generate resolv.conf
for you.
This has been resolved since few windows versions ago.
This problem still exists on Windows 11 build 22621.1265 on a fairly fresh install.
To prevent rebooting the whole system, you can try: wsl-restart.bat
To prevent rebooting the whole system, you can try:
wsl-restart.bat
Perhaps Microsoft can just fix their shit. This has been open since (early) 2020 ffs
wsl --shutdown makes my system back, but this is not really a solution. All unsaved work are lost and very inconvenient. I really wish Microsoft can solve this issue.
Not sure why, but after 6 months of constantly looking for a solution. This command fixed the issue (see: link):
sudo rm -rf /etc/acpi/events
Hi. Can you please collect networking logs by following the instructions below? https://github.com/microsoft/WSL/blob/master/CONTRIBUTING.md#collect-wsl-logs-for-networking-issues
Your Windows build number:
10.0.19582.1001
What you're doing and what's happening:
Originally found this problem while using X410 (X Server for Windows 10) with WSL2. I was able to confirm the same problem with much simpler program, netcat (https://en.wikipedia.org/wiki/Netcat).
The following problem only happens when TCP connections are made from WSL2 to Windows. When connections are made from Windows to WSL2, they are restored after sleep mode as expected.
netcat for Windows is available as an executable in Nmap package (https://nmap.org/download.html) You don't need to install it. You just need to download its command-line ZIP file, unzip, go to that unzipped folder in PowerShell or Windows Command Prompt and execute the ncat.exe as shown above.
The above command puts ncat.exe into a server mode (-l) waiting for data at the port 9999 (-p).
If you have a WSL1, you can also use its 'nc' command. For example, if you have Debian in WSL1 and Ubuntu in WSL2, you can run "nc -l -p 9999 -v" in Debian and get the same result.
I used the "Ubuntu 18.04" installed from Microsoft Store.
2.1 Get the IP address for Windows host
2.2 Connect to the IP address found in Step 2.1
Assuming the IP address is 172.18.16.1:
2.3 You should get connection succeeded messages for both ncat.exe in Windows and nc in WSL2.
Type some text and press [ENTER] in Windows (ncat.exe) and WSL2 (nc). You should be able to confirm that the connection is active and working in both directions as expected.
Put your computer to Sleep (Windows Start -> Power -> Sleep)
After confirming that your computer is fully in sleep mode, wake it up.
ncat.exe in Windows shows that the connection is lost, but nc in WSL2 thinks the connection is still active.
What's wrong / what should be happening instead:
The network connection between WSL2 and Windows is completely restored after waking up from Windows sleep mode.
The same problem can be observed with Hyper-V virtual machines (TCP connections made from VM to Windows). However, I can work around it by using its VSOCK feature. But, as far as I can tell, there seems to be no plan for VSOCK or AF_UNIX in WSL2.
All in all, such problem can be fatal for developers who create server programs for Windows that can be used by Linux apps running in WSL2.