You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Store WSL currently isn't accessible from session 0 contexts.
This means that it's not possible to interact with WSL from remote sessions such as ssh or psremote.
If wsl.exe is called from session 0, it will exit and display:
Access is denied.
on stdout.
Reacted by Ray Yano | あねてあ, Hasan Mohsin, Samuel Bahr, Mathias Kallmert, AntoineGlacet, Sebastian Kowalczyk, Benjamin Floyd, felixsmli, rfc2119, Cristian Novac and 61 more
Reacted by Pavel Selivanov, Mark O. Brown, pedr.o, Raimund58, Mauro Asprea and Ren Hiyama
Reacted by Jack Haden-Enneking, Douglas, Mathias Kallmert, Cameron Jackson, Georg Perhofer, Keith Bentrup, Erwan BERNARD, Alex Kuretz, David Fredman, eur2fe and 20 more
Reacted by Sanqui, Simon Bauer and mozhuanzuojing
Reacted by enachi, felixsmli, Abhishek Bhattacharya and mozhuanzuojing
Reacted by Mark O. Brown, masterflitzer, mozhuanzuojing, kaplan2539 and kitty
This is a deal breaker for some. Would be nice to get notice when it is solved. Thanks!
Reacted by Ray Yano | あねてあ, Ivan Bozhanov, enachi, Carlos Betancourt, felixsmli, Steven Chou, slushbox, Andy Salnikov, Rafal Sawicki, Piotr Łuczak and 37 more
Impact of this issue is complicated by the fact the store packaged version appears to now be required on the latest windows 11 insiders build (10.0.25267). Still looking for workarounds...
If policies make it difficult to enable Windows openssh to run WSL, an alternative/workaround might be to run a second openssh server (using a different port) within WSL. At the moment this seems not to be possible. But maybe that possibility can be enabled?
I am surprised by this. By default, I can access wsl from the native OpenSSH server by setting HKEY_LOCAL_MACHINE\SOFTWARE\OpenSSH to C:\Windows\System32\wsl.exe. I am using the store version with Ubuntu LTS 22.04
My problem is actually this: every time I initiate a SSH connection, I get a new WSL shell. I am unable to return back to the same session in case of disconnection events; all my background processes are gone. Each connection is therefore a new WSL instance.
I am surprised by this. By default, I can access wsl from the native OpenSSH server by setting HKEY_LOCAL_MACHINE\SOFTWARE\OpenSSH to C:\Windows\System32\wsl.exe. I am using the store version with Ubuntu LTS 22.04
I've tried it back and forth on different installs several times, and it never worked. It's a few months ago - should it be fixed and noone here knows? Many have the issue, and it's even acknnowledged by MS... Weird!
My problem is actually this: every time I initiate a SSH connection, I get a new WSL shell. I am unable to return back to the same session in case of disconnection events; all my background processes are gone. Each connection is therefore a new WSL instance.
Should I open another ticket for this ?
I don't think so: interrupted ssh sessions are like logoffs, like closing a terminal emulator (historically speaking closing a terminal emulator is like logging off ;-) ) - you wouldn't expect to get your jobs back there, right... You want to look into tmux or something alike. They keep processes running wile you're off, and you can attach back to them from another shell...
Reacted by Václav Brožík, Huy Z, Rene Schmidt, Eric Mink and Tim Brooks
I've tried it back and forth on different installs several times, and it never worked. It's a few months ago - should it be fixed and noone here knows? Many have the issue, and it's even acknnowledged by MS... Weird!
This looks weird indeed. Let me know if any of you would like more details. I just installed the "Ubuntu" app in the store using a local account.
You want to look into tmux or something alike. They keep processes running wile you're off, and you can attach back to them from another shell
It's exactly that! I don't find my tmux sessions when I log back in. In fact, I don't find the tmux process at all!
It's exactly that! I don't find my tmux sessions when I log back in. In fact, I don't find the tmux process at all!
I have no experience with tmux in WSL, so I can't comment from experience. But I'd think about whether your WSL - instance keeps running all the time, or wheter it has had a "reboot" in your time off - even tmux doesn't survive that ;-) Though maybe it can be made to autostart and continue processes? Dunno. I know that WSL's wakeup behavior from suspend is broken (it was in my version) - maybe another reason why tmux might vanish?
Or maybe you need to start your tmux processes in a local shell and let that run? Maybe you can then attach to running tmux from ssh and not shut WSL down by logging off?
And just to let others know: I did install the MS Store update again, and was immediately cut out of ssh-ing in. Fortunately it is enough to uninstall via the App-Icon that appears after the update, and the previous state returns... (i.e. no total reinstall of WSL required)
And yes, if I started tmux in a local shell and kept it running, I can ssh in and out multiple times and see that tmux live on happily...
Final remark for others like me who didn't realize (what for again others is likely self-evident): if it's just about ssh-ing into a running WSL from the outside (i.e. not about actually "booting" wsl): that is possible with the store version of wsl too. You access the host into a shell that doesn't depend on wsl, and from there you ssh into the running wsl: ssh -p n localhost. I guess sshd inside wsl needs to listen on a different port (n) than "outer"-Window's sshd (edit /etc/ssh/sshd_config). For my requirements that's actually tolerable ;-) , and one might consider the inability to start/stop wsl in a ssh-schell a protection of running processes inside wsl.
As Rainer Schütz (@bagong) mentioned it is possible to install and run a second OpenSSH server (using a different port) in your WSL instance as a workaround.
This can then be combined with using the ProxyJump directive to transparently connect to the second OpenSSH server by jumping through the win32 OpenSSH server. The directive can be added to the remote system's ~/.ssh/config:
I attempted the nssm solution recommended by Ren Hiyama (@renhiyama) Unfortunately, it does not seem to work on our Windows Server 2022 Standard via administrator user in logon settings. It simply does not want to start up WSL after I reboot the server.
Is there no way I can keep WSL booting automatically at server reboot, without needing me to log in, as we mainly access the server via RDP. Once I sign out, it closes the WSL app. Right now we are force-killing RDP just so we can "keep it running". But is not reliable.
I attempted the nssm solution recommended by Ren Hiyama (@renhiyama) Unfortunately, it does not seem to work on our Windows Server 2022 Standard via administrator user in logon settings. It simply does not want to start up WSL after I reboot the server.
Is there no way I can keep WSL booting automatically at server reboot, without needing me to log in, as we mainly access the server via RDP. Once I sign out, it closes the WSL app. Right now we are force-killing RDP just so we can "keep it running". But is not reliable.
Any tips will be appreciated.
See the comment earlier by aki-k , he had to REMOVE administrator group rights from that user who is configured to start WSL in order for this method to work, and if this is true, then your current method would fail. I didn't test it, as I run my system as a user (myself) with admin rights on Windows 11 and it seems work just fine.
You can try both and see which way works for you. I attached some screenshots
Anyone managed to get it working under Server 2025 ?
Tried the solution with NSSM but didn't work on boot rather when i was logged in with "nssm start wsl"
Guys, I think I have found the final solution, thanks to @rgl for letting me know the absolute path of proper wsl file, and @bayeslearner about this NSSM cli :) I guess I shouldn't credit myself, but the last missing piece was as simple as using a sleep infinity only, not even needing systemctl or sleep commands too. Here's the guide:
install NSSM, probably by choco install nssm in admin terminal.
type nssm install wsl, and write this stuff:
goto log on, and select "this account", get your username by typing whoami in another terminal if you dont know ur proper username, and put in your password u use to login too.
click save button, and then type in nssm start wsl, it should show smt like this:
now you can see your task manager, wsl will be running 24/7 regardless whether there's any open terminal or not. It also starts this service on boot 👍
I now just need to find why wsl uses so much cpu and disk even when idle...
I'm also experiencing high CPU usage while using NSSM. The CPU spikes for about 10 seconds every 1 or 2 minutes, causing my fan to spin frequently, which is really annoying. However, everything is fine when I open WSL normally.
PS:After a few test, I believe it has something to do with argument "sleep infinity"
This MSI does not replace your current WSL setup. It supplements it by installing WSL to an alternate location under C:\Program Files\WSL, which does support execution in Session 0.
The original wsl.exe under C:\Windows\System32\ still exists but cannot be used in automation scenarios that involve Session 0.
To work around the Session 0 limitation, use PowerShell as the executable and pass the wsl command as an argument. The screenshot below shows a working configuration:
Configuration details:
Action: Start a program
Program/script: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
Add arguments (optional): wsl -d Ubuntu-24.04
Note: The distribution name (e.g., Ubuntu-24.04) used in the task configuration is just an example. The actual name may vary depending on the version of the distro installed on your system. You can verify the exact name by running wsl -l in a PowerShell or Command Prompt window.
Validation:
After a reboot, without logging in:
Wait a few minutes.
Log in and check:
System uptime
WSL distribution uptime
If they match, the distro successfully launched from Session 0 via the scheduled task.
marlonmbcr Thanks a lot. I was asking chatgpt the whole day to find a fix for this. it didn't help. Your comment solved everything...
wow. Thanks again.
Guys, I think I have found the final solution, thanks to @rgl for letting me know the absolute path of proper wsl file, and @bayeslearner about this NSSM cli :) I guess I shouldn't credit myself, but the last missing piece was as simple as using a sleep infinity only, not even needing systemctl or sleep commands too. Here's the guide:
install NSSM, probably by choco install nssm in admin terminal.
type nssm install wsl, and write this stuff:
goto log on, and select "this account", get your username by typing whoami in another terminal if you dont know ur proper username, and put in your password u use to login too.
click save button, and then type in nssm start wsl, it should show smt like this:
now you can see your task manager, wsl will be running 24/7 regardless whether there's any open terminal or not. It also starts this service on boot 👍
I now just need to find why wsl uses so much cpu and disk even when idle...
I'm also experiencing high CPU usage while using NSSM. The CPU spikes for about 10 seconds every 1 or 2 minutes, causing my fan to spin frequently, which is really annoying. However, everything is fine when I open WSL normally.
PS:After a few test, I believe it has something to do with argument "sleep infinity"
This MSI does not replace your current WSL setup. It supplements it by installing WSL to an alternate location under C:\Program Files\WSL, which does support execution in Session 0.
The original wsl.exe under C:\Windows\System32\ still exists but cannot be used in automation scenarios that involve Session 0.
To work around the Session 0 limitation, use PowerShell as the executable and pass the wsl command as an argument. The screenshot below shows a working configuration:
Configuration details:
Action: Start a program Program/script: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe Add arguments (optional): wsl -d Ubuntu-24.04
Note: The distribution name (e.g., Ubuntu-24.04) used in the task configuration is just an example. The actual name may vary depending on the version of the distro installed on your system. You can verify the exact name by running wsl -l in a PowerShell or Command Prompt window.
Validation:
After a reboot, without logging in:
Wait a few minutes. Log in and check: System uptime WSL distribution uptime If they match, the distro successfully launched from Session 0 via the scheduled task.
For anyone who would like to try out marlonmbcr's solution in Windows 11: It would fail.
Guys, I think I have found the final solution, thanks to @rgl for letting me know the absolute path of proper wsl file, and @bayeslearner about this NSSM cli :) I guess I shouldn't credit myself, but the last missing piece was as simple as using a sleep infinity only, not even needing systemctl or sleep commands too. Here's the guide:
install NSSM, probably by choco install nssm in admin terminal.
type nssm install wsl, and write this stuff:
goto log on, and select "this account", get your username by typing whoami in another terminal if you dont know ur proper username, and put in your password u use to login too.
click save button, and then type in nssm start wsl, it should show smt like this:
now you can see your task manager, wsl will be running 24/7 regardless whether there's any open terminal or not. It also starts this service on boot 👍
I now just need to find why wsl uses so much cpu and disk even when idle...
I'm also experiencing high CPU usage while using NSSM. The CPU spikes for about 10 seconds every 1 or 2 minutes, causing my fan to spin frequently, which is really annoying. However, everything is fine when I open WSL normally.
PS:After a few test, I believe it has something to do with argument "sleep infinity"
any solution for the spike?
remove the quotes from "sleep infinity" running wsl "sleep infinity" results in /bin/bash: line 1: sleep infinity: command not found so the service just keeps restarting in a loop, wsl sleep infinity is the correct command
Activity
[-]Store WSL isn't accessible in Session 0[/-][+]Store WSL isn't accessible from Session 0[/+]yanorei32 commentedon Dec 1, 2022
I think this issue is already tracked internally.
However, this problem continues even now.
https://learn.microsoft.com/en-us/windows/wsl/store-release-notes#known-issues
benhillis commentedon Dec 1, 2022
Known issue, we're working on a solution.
bagong commentedon Dec 9, 2022
This is a deal breaker for some. Would be nice to get notice when it is solved. Thanks!
vakata commentedon Dec 15, 2022
Please fix this - I cannot remotely login to WSL using the builtin OpenSSH server, my scheduled tasks also stopped working.
brentmjohnson commentedon Dec 20, 2022
Impact of this issue is complicated by the fact the store packaged version appears to now be required on the latest windows 11 insiders build (10.0.25267). Still looking for workarounds...
#9355
#9373
enachi commentedon Dec 20, 2022
I had to uninstall store version of WSL to be able to run ssh server at system startup again
bagong commentedon Dec 22, 2022
If policies make it difficult to enable Windows openssh to run WSL, an alternative/workaround might be to run a second openssh server (using a different port) within WSL. At the moment this seems not to be possible. But maybe that possibility can be enabled?
rfc2119 commentedon Jan 1, 2023
I am surprised by this. By default, I can access wsl from the native OpenSSH server by setting
HKEY_LOCAL_MACHINE\SOFTWARE\OpenSSHtoC:\Windows\System32\wsl.exe. I am using the store version with Ubuntu LTS 22.04My problem is actually this: every time I initiate a SSH connection, I get a new WSL shell. I am unable to return back to the same session in case of disconnection events; all my background processes are gone. Each connection is therefore a new WSL instance.
Should I open another ticket for this ?
bagong commentedon Jan 1, 2023
I've tried it back and forth on different installs several times, and it never worked. It's a few months ago - should it be fixed and noone here knows? Many have the issue, and it's even acknnowledged by MS... Weird!
I don't think so: interrupted ssh sessions are like logoffs, like closing a terminal emulator (historically speaking closing a terminal emulator is like logging off ;-) ) - you wouldn't expect to get your jobs back there, right... You want to look into tmux or something alike. They keep processes running wile you're off, and you can attach back to them from another shell...
rfc2119 commentedon Jan 1, 2023
This looks weird indeed. Let me know if any of you would like more details. I just installed the "Ubuntu" app in the store using a local account.
It's exactly that! I don't find my tmux sessions when I log back in. In fact, I don't find the tmux process at all!
bagong commentedon Jan 1, 2023
I have no experience with tmux in WSL, so I can't comment from experience. But I'd think about whether your WSL - instance keeps running all the time, or wheter it has had a "reboot" in your time off - even tmux doesn't survive that ;-) Though maybe it can be made to autostart and continue processes? Dunno. I know that WSL's wakeup behavior from suspend is broken (it was in my version) - maybe another reason why tmux might vanish?
Or maybe you need to start your tmux processes in a local shell and let that run? Maybe you can then attach to running tmux from ssh and not shut WSL down by logging off?
And just to let others know: I did install the MS Store update again, and was immediately cut out of ssh-ing in. Fortunately it is enough to uninstall via the App-Icon that appears after the update, and the previous state returns... (i.e. no total reinstall of WSL required)
And yes, if I started tmux in a local shell and kept it running, I can ssh in and out multiple times and see that tmux live on happily...
Final remark for others like me who didn't realize (what for again others is likely self-evident): if it's just about ssh-ing into a running WSL from the outside (i.e. not about actually "booting" wsl): that is possible with the store version of wsl too. You access the host into a shell that doesn't depend on wsl, and from there you ssh into the running wsl:
ssh -p n localhost. I guess sshd inside wsl needs to listen on a different port (n) than "outer"-Window's sshd (edit /etc/ssh/sshd_config). For my requirements that's actually tolerable ;-) , and one might consider the inability to start/stop wsl in a ssh-schell a protection of running processes inside wsl.joes commentedon Jan 16, 2023
As Rainer Schütz (@bagong) mentioned it is possible to install and run a second OpenSSH server (using a different port) in your WSL instance as a workaround.
This can then be combined with using the
ProxyJumpdirective to transparently connect to the second OpenSSH server by jumping through the win32 OpenSSH server. The directive can be added to the remote system's~/.ssh/config:The above example assumes that the second OpenSSH server in wsl is running on port 2222.
Using this configuration it is then possible to connect to the wsl instance via the hostname
openssh_wsl:138 remaining items
aki-k commentedon Jun 18, 2024
kundeng I had to remove the local Administrators group membership from the user that starts the WSL 2 VM/instance on boot.
whitetiger264 commentedon Aug 28, 2024
I attempted the
nssmsolution recommended by Ren Hiyama (@renhiyama) Unfortunately, it does not seem to work on our Windows Server 2022 Standard viaadministratoruser in logon settings. It simply does not want to start up WSL after I reboot the server.Is there no way I can keep WSL booting automatically at server reboot, without needing me to log in, as we mainly access the server via RDP. Once I sign out, it closes the WSL app. Right now we are force-killing RDP just so we can "keep it running". But is not reliable.
Any tips will be appreciated.
kundeng commentedon Aug 29, 2024
See the comment earlier by aki-k , he had to REMOVE administrator group rights from that user who is configured to start WSL in order for this method to work, and if this is true, then your current method would fail. I didn't test it, as I run my system as a user (myself) with admin rights on Windows 11 and it seems work just fine.
You can try both and see which way works for you. I attached some screenshots
c-michail commentedon Feb 3, 2025
Anyone managed to get it working under Server 2025 ?
Tried the solution with NSSM but didn't work on boot rather when i was logged in with "nssm start wsl"
tjc0726 commentedon Apr 12, 2025
I'm also experiencing high CPU usage while using NSSM. The CPU spikes for about 10 seconds every 1 or 2 minutes, causing my fan to spin frequently, which is really annoying. However, everything is fine when I open WSL normally.
PS:After a few test, I believe it has something to do with argument "sleep infinity"
marlonmbcr commentedon Apr 22, 2025
Hi everybody let me know if helps, at least in my test lab this solution worked.
A workaround is available for Windows Server 2022, using a Microsoft-supplied MSI installer that complements the existing WSL installation.
Releases · microsoft/WSL
Key Points:
This MSI does not replace your current WSL setup. It supplements it by installing WSL to an alternate location under C:\Program Files\WSL, which does support execution in Session 0.
The original wsl.exe under C:\Windows\System32\ still exists but cannot be used in automation scenarios that involve Session 0.
To work around the Session 0 limitation, use PowerShell as the executable and pass the wsl command as an argument. The screenshot below shows a working configuration:
Configuration details:
Action: Start a program
Program/script: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
Add arguments (optional): wsl -d Ubuntu-24.04
Note: The distribution name (e.g., Ubuntu-24.04) used in the task configuration is just an example. The actual name may vary depending on the version of the distro installed on your system. You can verify the exact name by running wsl -l in a PowerShell or Command Prompt window.
Validation:
After a reboot, without logging in:
Wait a few minutes.
Log in and check:
System uptime
WSL distribution uptime
If they match, the distro successfully launched from Session 0 via the scheduled task.
parsalotfy commentedon May 7, 2025
marlonmbcr Thanks a lot. I was asking chatgpt the whole day to find a fix for this. it didn't help. Your comment solved everything...
wow. Thanks again.
c-michail commentedon May 7, 2025
marlonmbcr is this working on Win2025 ?
Loyola-London commentedon Jun 27, 2025
chmichael
Yes. Works on Server 25.
FWIW, I use this method to start wsl and keepwsl to keep wsl alive.
shreyasvasista17 commentedon Dec 2, 2025
any solution for the spike?
MB-68463: Use absolute path for wsl call when building Erlang
tingjhenjiang commentedon Jul 25, 2026
For anyone who would like to try out marlonmbcr's solution in Windows 11: It would fail.
alanb-sony commentedon Jul 28, 2026
remove the quotes from
"sleep infinity"runningwsl "sleep infinity"results in/bin/bash: line 1: sleep infinity: command not foundso the service just keeps restarting in a loop,wsl sleep infinityis the correct commandfix(wsl): run YubiKey attach task as user, not SYSTEM, and hide windo…
docs(setup): the headless Windows recipe could fail silently after a …