WSL: wsl.exe fails with "Access is denied"
After uninstalling an re-installing Windows Subsystem for Linux I can’t install any distro - they all fail with “Access is denied”. Even running wsl.exe now fails with “Access is denied”.
Your Windows build number: (Type ver at a Windows Command Prompt)
Microsoft Windows [Version 10.0.18362.657]
Steps to reproduce
> wsl.exe
Access is denied
Strace and logs attached.
About this issue
- Original URL
- State: open
- Created 7 years ago
- Reactions: 26
- Comments: 74
Had the same issue when running as admin, when running without it WSL works fine. try it.
Yes - grant your user account full control over the .vhdx file. See https://answers.microsoft.com/en-us/windows/forum/all/kb4565503-installed-then-wsl-2-failed-to-start/25794c4f-0b20-465e-bbdb-a8af3d9e0e88
Fixed after running the following in PowerShell as administrator
If anyone are facing this problem, check if you have an App called Windows Subsystem for Linux, if yes, uninstall it and you will get access to wsl2 again.
It was installed here after running
wsl --updatecommand.I have the same issue on an Ubuntu installation imported from a TAR file to a custom location. I already have access to the WindowsApps folder; this doesn’t help.
Running as a regular user: I get the “Access Denied” message when trying to start wsl.exe. Running as Administrator": wsl.exe works to .start the distro running. I can then use it either as admin or as a regular user (via wsl.exe, Windows Terminal, VS Code…) However, if the distro shuts down (e.g. via
wsl.exe --shutdown), then I lose my ability to connect as a regular user, and have to run wsl.exe as admin again.Problem seems to have appeared with Windows Update KB4565503 earlier this week.
EDIT: After uninstalling KB4565503, the problem disappears.
amazing. simply amazing. so
wsl.exe --updatetakes away the possibility to usewsl.execommand line. thus for example completely breaking Docker.how could this ever have slipped through Microsoft’s quality control?! and it’s been this way since at least 8 months?!
Same over here.
Switched from WSL 1 to WSL 2. After rebooting I got an Access is denied. Later I found that I didn’t have Windows Version 2004, Build 19041 install but only 1909 Build 18363.720.
So I removed WSL from Windows Features, reboot, and activated WSL again with the effect that I get an “Access is denied” in PS being Admin but runs without Admin. However, I’m stuck now since I can no longer use wsl.exe being Admin nor revert to any previous state.
I seem to ahve the same issue… Although I can start ubuntu when I open it from the store, executing wsl always results in " Access is denied".
So during not even a full year, Microsoft was able to completely break Docker via WSL two times via bodged updates - creating a massive amount of wasted working hours and annoyance. 👏🏼🤡
This appears to be due to a windows update causing WSL.exe to trigger an attack surface reduction rule in defender for endpoint.
https://learn.microsoft.com/en-us/defender-endpoint/attack-surface-reduction-rules-deployment-test#step-2-understand-the-attack-surface-reduction-rules-reporting-page-in-the-microsoft-defender-portal - Your IT admins can use this report to see if wsl.exe is triggering the rule.
We confirmed this was the issue for our users after installing the latest updates pushed on 08.13.
From here we went into the intune ASR policy and set an exemption for WSL.exe (decent write up here, this is not our page - https://www.nielskok.tech/microsoft-defender-for-endpoint/add-exclusion-in-attack-surface-reduction-microsoft-defender-for-endpoint/)
We tested by running
gpupdate /forceon impacted devices and rebooting. After reboot, we were able to resume normal ops.I suddenly had this problem. I have been working using an administered laptop and have been using WSL Ubuntu for work environment. Laptop went to sleep and when turned on VSCode and cmd couldn’t access WSL.
Issue #5605 has a possible “permanent” fix for the issue triggered by
KB4565503.Also got past this with WindowsApps folder permissions. You need to change the owner of this folder so you can get access to it. Try this link (ignoring the stupid download an app version 1 of course 😃 https://www.maketecheasier.com/access-windowsapps-folder-windows-10/
If you are using intune to manage these devices your intune admin will need to go into the attack surface reduction rules and exempt WSL from there then you can run a group policy update and reboot.
You may be able to look at the windows protection history and see if this is the case:
https://github.com/microsoft/WSL/issues/4920#issuecomment-2291906640
Same here, seemed to happen after installing the latest Windows Updates:
@vncntk Seconding this, the exact same thing happened to me today as well. Have not found a solution yet either.
I too have this issue but in my case, McAfee endpoint security is installed on my machine and it is blocking me to run it. In the McAfee endpoint security, the below message was posted. The windows update KB4565503 is NOT installed on my machine.
I found the resolution from the below source. Source: answers.microsoft.com
I experienced this issue when Docker stopped unexpectedly.
PowerShell would either return that I didn’t have permission (when run outside Administrator) or Access Denied (when run as Administrator. In a command prompt I was getting Access Denied when trying to run wsl, but was still able to run wsl --help.
If you are able to run wsl --help and get information back, you should be able to do the following:
wsl --list --verboseto get a list of distroswsl --shutdownwsl --unregister [distro name listed from step 1]Then I had located ext4.vhdx and deleted the folders in AppData that contained this file (Mine was Docker). If you can’t delete it because it says it is open in System, restart and you should be able to delete it. After it’s deleted, you should have access to wsl in PowerShell and cmd and be able to reinstall the distro you deleted.
Same here. Just updated Win 10 yesterday and now my WSL2 throws “Access denied” but if you run terminal as administrator and then go to wsl, it works.
Can confirm the specific update (KB4565503) was the issue.
wslnow works perfectly and doesn’t say access denied.I have the same problem. I followed these steps https://docs.microsoft.com/pt-br/windows/wsl/install-win10 And got stucked in the part I had to switch to version 2. I can’t simply run
wslbecause windwos always say Access DeniedSame for me, the solution provided by @dylancarruthers solved the issue when in Administrator mode. Docker Desktop also stopped working because of this and resolved that by:
wsl --unregister docker-desktopIf you have WSL “Access is denied” problem, at first check where have you your WSL installed. If you use WSL from Microsoft Store (it is good choice, because you have got fresh and current version) then WSL is installed in
C:\Program Files\WindowsApps\folder. And this folder has very limited access. Local administrators can’t access this folder. I took over ownership of files in this directory to LOCAL-DOMAIN\Administrators. Then it was possible to add Read/Execute rights to LOCAL-DOMAIN\Administrators. After it WSL start working via SSH or other remote access.I started recently getting File permission errors when trying to edit anything under
\\wsl$\Ubuntu-20.04from Windows Explorer, opening in VSCode. In the end I resorted to unregistering from Powershell (wsl --shutdownandwsl --unregister Ubuntu-20.04), and then re-installing (I just clicked on the Ubuntu icon which I had pinned in the taskbar, and it reinstalled). After reinstalling and creating the new user, now I can access and edit files using Windows Explorer and VSCode.Unfortunately this has the downside of removing all data within the Ubuntu instance. It seems to me to be a pretty drastic approach. I had already checked permissions on the
ext4.vhdxfile (C:\%USERPROFILE%\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu20.04onWindows_79rhkp1fndgsc\LocalState\ext4.vhdx) and they were all correct as far as I could tell.@koleh-tech Defender was the cause for us too with this rule: Block use of copied or impersonated system tools. If you can check your protection history in Defender you might see all the blocked wsl.exe actions.
For anyone who might still be stuck here, this solution worked for me:
Quoting from that solution:
wsl --unregister ubuntufollowed bywsl --installfixes the problem for ubuntu atleastHad simillar problem. Running as administator won’t help. (Access Denied) After some manipulations, I’ve decided to turn off Windows Update Blocker (wub)
Now, WSL works
I just fixed it.
wsl --import Ub C:\Users\fs\wsl\Ub C:\Users\fs\backup\wsl\wsl.tar.gz --version 2worked, whereaswsl --import Ub C:\Users\fs\wsl\Ub C:\Users\fs\backup\wsl\wsl.tar --version 2failed. I don’t know why I decided to unpack the gz file in the first attempt and tried to import from there.In my case, windows permission mixed up with linux permissions, and disabled the
xattribute on my folders, so I couldn’t read them.I had to do
I had already installed Ubuntu on my machine a while ago. Today I found I could not start it:
i. Trying to click “Ubuntu” in the Start Menu would appear to not react, ii. trying to start it from
cmd.exewould exit immediately.What did work, was to start
cmd.exeorpowershell.exeas Administrator and runwslfrom there:I tried to reinstall:
It appeared to install successfully, however I still had the same symptoms.
I tried reinstalling again, this time directly in my user account:
It didn’t solve it, but instead of Ubuntu crashing immediately, it told me:
(which is what brought me to this thread)
but it still works as Administrator.
@jwsinner’s fix in https://github.com/microsoft/WSL/issues/4920#issuecomment-746843348 seems to have actually fixed it fully! And done it without having to garble my system permissions or anything:
In my Administrator shell:
Then, as my regular user, without reinstalling anything package:
I’m -1 on KB4565503 being the problem. I don’t have it installed:
I have Windows 10 Pro N-1909-18363.1440:
~@codemonkey33 has the solution that worked just fine for me. I still had the problem even when I had imported my ubuntu outside of the
WindowsAppsfolder, weird…~EDIT: @rosea-tf has pinpointed the bug below. It only happens once wsl is shutdown by itself. You’ll have to access wsl as admin and then you’ll have access again.