Skip to content

Store WSL isn't accessible from Session 0 #9231

Open

Description

@OneBlue

Version

Multiple versions are affected

WSL Version

  • WSL 2
  • WSL 1

Kernel Version

No response

Distro Version

No response

Other Software

No response

Repro Steps

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.

Activity

  1. changed the title [-]Store WSL isn't accessible in Session 0[/-] [+]Store WSL isn't accessible from Session 0[/+] on Nov 29, 2022
  2. yanorei32 commented on Dec 1, 2022

    @yanorei32

    I think this issue is already tracked internally.
    However, this problem continues even now.

    Release Notes for Windows Subsystem for Linux in the Microsoft Store

    ...

    Known Issues:

    • Launching Windows Subsystem for Linux from session zero does not currently work (for example from an ssh connection).

    https://learn.microsoft.com/en-us/windows/wsl/store-release-notes#known-issues

  3. benhillis commented on Dec 1, 2022

    @benhillis
    Member

    Known issue, we're working on a solution.

  4. bagong commented on Dec 9, 2022

    @bagong

    This is a deal breaker for some. Would be nice to get notice when it is solved. Thanks!

  5. vakata commented on Dec 15, 2022

    @vakata

    Please fix this - I cannot remotely login to WSL using the builtin OpenSSH server, my scheduled tasks also stopped working.

  6. brentmjohnson commented on Dec 20, 2022

    @brentmjohnson

    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

  7. enachi commented on Dec 20, 2022

    @enachi

    Please fix this - I cannot remotely login to WSL using the builtin OpenSSH server, my scheduled tasks also stopped working.

    I had to uninstall store version of WSL to be able to run ssh server at system startup again

  8. bagong commented on Dec 22, 2022

    @bagong

    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?

  9. rfc2119 commented on Jan 1, 2023

    @rfc2119

    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.

    Should I open another ticket for this ?

  10. bagong commented on Jan 1, 2023

    @bagong

    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...

  11. rfc2119 commented on Jan 1, 2023

    @rfc2119

    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!

  12. bagong commented on Jan 1, 2023

    @bagong

    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.

  13. joes commented on Jan 16, 2023

    @joes

    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:

    Host openssh_win32
        Hostname your_computer.local
        User windows_username
    
    Host openssh_wsl
       ProxyJump openssh_win32
       User wsl_username
       HostName localhost
       Port 2222

    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:

    ssh openssh_wsl
  14. 138 remaining items

  15. aki-k commented on Jun 18, 2024

    @aki-k

    kundeng I had to remove the local Administrators group membership from the user that starts the WSL 2 VM/instance on boot.

  16. whitetiger264 commented on Aug 28, 2024

    @whitetiger264

    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.

  17. kundeng commented on Aug 29, 2024

    @kundeng

    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

    image
    image
    image

  18. c-michail commented on Feb 3, 2025

    @c-michail

    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"

  19. tjc0726 commented on Apr 12, 2025

    @tjc0726

    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:
      image
    • 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:
      image

    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 👍 image

    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"

  20. marlonmbcr commented on Apr 22, 2025

    @marlonmbcr

    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

    Image

    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.

    Image

    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.

    Image

    Image

    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.

    Image

  21. parsalotfy commented on May 7, 2025

    @parsalotfy

    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.

  22. c-michail commented on May 7, 2025

    @c-michail

    marlonmbcr is this working on Win2025 ?

  23. Loyola-London commented on Jun 27, 2025

    @Loyola-London

    chmichael

    Yes. Works on Server 25.

    FWIW, I use this method to start wsl and keepwsl to keep wsl alive.

  24. shreyasvasista17 commented on Dec 2, 2025

    @shreyasvasista17

    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:
      image
    • 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:
      image

    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 👍 image
    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?

  25. tingjhenjiang commented on Jul 25, 2026

    @tingjhenjiang

    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

    Image

    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.

    Image

    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.

    Image

    Image

    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.

    Image

    For anyone who would like to try out marlonmbcr's solution in Windows 11: It would fail.

  26. alanb-sony commented on Jul 28, 2026

    @alanb-sony

    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:
      image
    • 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:
      image

    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 👍 image
    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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions