microsoft / WSL

Issues found on WSL
https://docs.microsoft.com/windows/wsl
MIT License
17.23k stars 808 forks source link

WSL2 distro failing to startup with code 4294967295 #5092

Open bitcrazed opened 4 years ago

bitcrazed commented 4 years ago

image

Then tried connecting to distro via Windows Terminal, but got:

A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. [process exited with code 4294967295]

image

Can no longer access my Ubuntu WSL distro at all.

nevgeniev commented 3 years ago

running wsl from admin power shell solved issue for me. looks like there're different problems with same outcome (error code)

satyakaamm commented 3 years ago

Stopping Hyper-V service from Hyper-V manager app solved this issue.

WSL works on Windows 10 Home when home version doesn't even have hyper-v support. So that might not be the solution.

Sam-Tymoshchuk commented 3 years ago

I had two wsl2 instances, and this issue first occurred after I set-up the second wsl2. None of the above solutions helped me, but I also I had an additional Virtual Switch configured with NAT for my VMs in Hyper-V, so once I removed this NAT with Remove-NetNat cmdlet and also removed the IP assigned to Virtual Switch with Remove-NetIPAddress the wsl2 started to work.

cgodo commented 3 years ago

For all those that tried all solutions above and could not solve the issue. In my case it turned out that my WSL2 virtual disk was corrupted. Probably happened after executing wsl --shutdown.

After some investigation, I managed to fix it with these steps.

1. Install another Linux distro in WSL 2 mode

You must run some linux commands and since you can't launch your current distro, you must install another one. In case you want to install the same version (for example, Ubuntu 20.04), check this: Manually download Windows Subsystem for Linux distro packages. For this example I used Ubuntu 20.04.

Remember to set that new distro to WSL 2 version. Also, remember to terminate completely your broken distro. Sometimes, even if it's not running, the WSL process still retains the VHDX file open. I recommend to run wsl --shutdown to ensure all distros are closed before continuing.

2. Launch the new distro and install libguestfs_tools and a generic kernel.

Libguestfs is a set of tools that will allow you to mount and repair your corrupted WSL2 VHDX drive. Install it in ubuntu with this: sudo apt-get install libguestfs-tools linux-image-generic

3. Locate your corrupted WSL2 drive

Your WSL2 distro drive is usually located in the folder where your distro is installed. The file you want to find is named "ext4.vhdx". You will need to know its full path in a linux format. In my case I had my Ubuntu distro installed in a custom folder in the D: drive so my path was /mnt/d/wsl/ubuntu/ext4.vhdx.

Make a backup of your vhdx file in another folder, just in case.

4. Repair your VHDX drive

Once you know the path of your drive, run this command to list the filesystems in your VHDX file: sudo virt-list-filesystems /mnt/d/wsl/ubuntu/ext4.vhdx

It should give you the name for the mount, in my case it was /dev/sda.

Then you are ready to repair the drive. Run this command to start a new recovery linux VM where you'll be able to repair your virtual drive: sudo virt-rescue -a /mnt/d/wsl/ubuntu/ext4.vhdx

Then in the new command prompt of that VM, run this command, using the name of the mount you found earlier: e2fsck -y /dev/sda

It should repair several things in your drive. Once it is done, run the command exit so it will sync all changes and exit the repair VM.

At this point, if all repairs went OK, your distro should be able to start again.

MLNW commented 3 years ago

@cgodo You good sir, just saved me!

ghost commented 3 years ago

https://github.com/microsoft/WSL/issues/5092#issuecomment-662611965

I made it work by following : #5092 (comment)

then kill SharedAccess service.

And it wasn't enough, so I opened a powershell with Admin grants and typed : wsl -l -v wsl bash wsl -l -v then it worked.

This is what fixed for me! I had the same issue happen to me after I created a symbolic link from where ext4.vhdx was located in my SSD to a new folder on my HD. If anyone is looking for how to do that as well, I followed the guide this blog post just be careful of your paths, in my case ext4.vhdx was in a folder called LocalState. Change your path from "Data" to "LocalState" and it'll work!

mqxie commented 3 years ago

Solve "process exited with code 4294967295" , run netsh winsock reset as Administrator, then reboot your computer. The result like below:

❯ netsh winsock reset

Sucessfully reset the Winsock Catalog.
You must restart the computer in order to complete the reset.

this is useful for me

devturi commented 3 years ago

I was seeing the same issue and managed to fix it (at least for now!)

I opened the Resource Monitor and checked the "Listening Ports" so I could see what processes were using port 53, and found dockerd.exe and svchost.exe.

As there are too many instances of svchost.exe I used the PID to find the process on Task Manager, right-clicked and selected "Go to Service" and found out that it was "SharedAccess" (ICS).

At this point I killed dockerd.exe and stopped SharedAccess service (that immediately started again) and that was enough for me to get WSL distro running again!

It worked for me.. Thank you so much. I had very important files on my wsl.

rachidbch commented 3 years ago

Just to add a data point for whoever is investigating this. I have WSL2 on Windows 10 20H2 Build 19042.746. I have Technitium DNS server installed on the same machine. Whenever I launch a Ubuntu WSL2 distribution with Technitium DNS server running, I get the error process exited with code 4294967295.

If I kill Technitium DNS and launch Ubuntu WSL2 everything works smoothly. I created an Issue on Technitium Github repo.

pmpaulino commented 3 years ago

I had a customer's VPN client installed on my machine (Cisco AnyConnect VPN), the customer's installation package also installed dnscrypt. Uninstalling this has resolved the issue on my machine, confirming other threads that indicate the issue is usually related to network issues... particularly port 53.

I have Private Internet Access set to startup automatically and that was the culprit. Disconnected from PIA and then I restarted Windows Terminal into WSL and voila I'm back in business.

ppavlovdev commented 3 years ago

I faced the same problem and I found solution for my specific case: as long as my laptop has no battery when I accidently pulled up power cable my BIOS switched back to default settings where virtualization option was in disabled mode. I entered into BIOS, switched on virtualization and WSL successfuly started.

Hope this helps!

yanglr commented 3 years ago

I met the same issue, solved by restarting Lxss Manger and Lxss Manger xxx services in Services, then restart my PC. Finally the issue gone.

Refered to: https://stackoverflow.com/questions/48407070/wsl-ubuntu-hangs-how-to-restart

robsonbmartins commented 3 years ago

Just run this atualization kernel in this .msi https://github.com/microsoft/WSL/issues/5393

For me work immediatly!

gui-sousa commented 3 years ago

Try

bcdedit /set hypervisorlaunchtype auto

shijistar commented 3 years ago

I've faced this problem too in an almost-new Windows 10 Pro install, just switched "back" from macOS. Update KB4571756 is successfully installed, and didn't solve the issue.

In the past (years ago), I used to use Acrylic DNS which is a DNS Proxy that will naturally listen on port 53 to do fancy things like serving my localhost projects on myproject.local just like dnsmasq does on *nix systems. Uninstalling it fixed it for me.

This means that using WSL is incompatible with using any kind of DNS Server, which is something you may want to keep in mind and perhaps may need to be included in the documentation.

I'm also having this problem with WSL and Acrylic both listening on port 53. My workaround was to find the Acrylic DNS Proxy service and set it to Automatic (Delayed). This way WSL starts normally and Acrylic still works properly.

snoopy82481 commented 3 years ago

None of the supplied instructions worked. But the below with modifications did the trick, as the issue I found was related to my fstab entry to connect to my NFS share. So here are the steps I used to fix my WSL 2 instance.

Follow steps 1-3 listed below then modify step 4 to the below:

4. Repair your VHDX drive

Once you know the path of your drive, run this command to list the filesystems in your VHDX file: sudo virt-list-filesystems /mnt/d/wsl/ubuntu/ext4.vhdx

It should give you the name for the mount, in my case it was /dev/sda.

Then you are ready to repair the drive. Run this command to start a new recovery linux VM where you'll be able to repair your virtual drive: sudo virt-rescue -a /mnt/d/wsl/ubuntu/ext4.vhdx -i This will mount your VM's filesystem to the recovery tool.

Then in the new command prompt of that VM, run the following commands: chroot /sysroot This gets you into the filesystem of the VM nano /etc/fstab

Then Remove the share entry in there. Save and Exit the editor

After that type exit to exit out of the VM and sync your changes.

You should be able to fire up your WSL instance and get access again.

Thank you @cgodo for providing amazing instructions to get into the recovery tool to make this change.

For all those that tried all solutions above and could not solve the issue. In my case it turned out that my WSL2 virtual disk was corrupted. Probably happened after executing wsl --shutdown.

After some investigation, I managed to fix it with these steps.

1. Install another Linux distro in WSL 2 mode

You must run some linux commands and since you can't launch your current distro, you must install another one. In case you want to install the same version (for example, Ubuntu 20.04), check this: Manually download Windows Subsystem for Linux distro packages. For this example I used Ubuntu 20.04.

Remember to set that new distro to WSL 2 version. Also, remember to terminate completely your broken distro. Sometimes, even if it's not running, the WSL process still retains the VHDX file open. I recommend to run wsl --shutdown to ensure all distros are closed before continuing.

2. Launch the new distro and install libguestfs_tools and a generic kernel.

Libguestfs is a set of tools that will allow you to mount and repair your corrupted WSL2 VHDX drive. Install it in ubuntu with this: sudo apt-get install libguestfs-tools linux-image-generic

3. Locate your corrupted WSL2 drive

Your WSL2 distro drive is usually located in the folder where your distro is installed. The file you want to find is named "ext4.vhdx". You will need to know its full path in a linux format. In my case I had my Ubuntu distro installed in a custom folder in the D: drive so my path was /mnt/d/wsl/ubuntu/ext4.vhdx.

Make a backup of your vhdx file in another folder, just in case.

4. Repair your VHDX drive

Once you know the path of your drive, run this command to list the filesystems in your VHDX file: sudo virt-list-filesystems /mnt/d/wsl/ubuntu/ext4.vhdx

It should give you the name for the mount, in my case it was /dev/sda.

Then you are ready to repair the drive. Run this command to start a new recovery linux VM where you'll be able to repair your virtual drive: sudo virt-rescue -a /mnt/d/wsl/ubuntu/ext4.vhdx

Then in the new command prompt of that VM, run this command, using the name of the mount you found earlier: e2fsck -y /dev/sda

It should repair several things in your drive. Once it is done, run the command exit so it will sync all changes and exit the repair VM.

At this point, if all repairs went OK, your distro should be able to start again.

JD-Gimbit commented 3 years ago

I've faced this problem too in an almost-new Windows 10 Pro install, just switched "back" from macOS. Update KB4571756 is successfully installed, and didn't solve the issue.

In the past (years ago), I used to use Acrylic DNS which is a DNS Proxy that will naturally listen on port 53 to do fancy things like serving my localhost projects on myproject.local just like dnsmasq does on *nix systems. Uninstalling it fixed it for me.

This means that using WSL is incompatible with using any kind of DNS Server, which is something you may want to keep in mind and perhaps may need to be included in the documentation.

I too had a dns server installed, removed it and it worked

patricknazar commented 3 years ago

I restarted Lxss Manager service and it worked. I usually just restart the PC. Seems to be another "first boot of the day" regression.

rubendavidp commented 3 years ago

None of these solutions are working for me.

I made it work by uninstalling "Windows Subsystem for Linux Update" and install it again.

Did it work?

PavelSosin-320 commented 3 years ago

@JD-Gimbit You are not right in saying that WSL is not compatible with any DNS server. It can work with any DNS in the LAN or WAN. Its configuration is not sufficient to work in the modern global DNS infrastructure. Ifdistro starts like Ubuntu 20.04 or using systemd-genie as systemd system there is NetworkManager and systemd-resolved configuration that provides enough options to work with any DNS, static and dynamic using any DNS protocol, network protocol, supported/required by the DNS service(!!!). GoogleDNS is always too far and ISP's DNS is always too limited to be reliable.

JD-Gimbit commented 3 years ago

@JD-Gimbit You are not right in saying that WSL is not compatible with any DNS server. It can work with any DNS in the LAN or WAN. Its configuration is not sufficient to work in the modern global DNS infrastructure. Ifdistro starts like Ubuntu 20.04 or using systemd-genie as systemd system there is NetworkManager and systemd-resolved configuration that provides enough options to work with any DNS, static and dynamic using any DNS protocol, network protocol, supported/required by the DNS service(!!!). GoogleDNS is always too far and ISP's DNS is always too limited to be reliable.

I'm not saying it doesn't work with DNS. I'm saying I had a 3rd party DNS server on my pc and removed it and my issue went away. The premise of your tirade is inaccurate. You should confirm before you go on the offensive, as I clearly said "I too had a dns server installed, removed it and it worked" where am I saying it's not compatible with any? You are also dealing with a thread that is intended to assist people where the WSL won't start. Please stay on topic. For reference technitium dns server was installed on my laptop, removing this resolved my issue.

PavelSosin-320 commented 3 years ago

@JD-Gimbit Sorry for the language that you see as offensive but saying that WSL has big problems with DNS using is misleading. Wise versa, WSL gives a great opportunity to use Linux network stack that is more effective and more manageable than Windows' network stack. I suppose all correctly built Linux distros implement the concepts and RFC standards described in the corresponding document. You can find that the configuration that possibly suitable for you is installed by default. The recommendations on how to configure DNS clients in the optimal for network technology, topology, and used DNS capability are provided in the configuration file although sane defaults are set during distro installation. In the scenario where a user has DNS proxy, DNS box, or DNS service running on the local WiFi router it is better to disable nameserver file generation in wsl.conf file and use Linux configuration solely. It can help to improve name resolution reliability and time 10-100 times without any additional hardware.

JD-Gimbit commented 3 years ago

@PavelSosin-320 I think you are confused, I replied to the comment. Once again, I never said WSL has a problem with DNS. I even quoted my reply in my last message. To make it easier for you, I have included a screenshot with my comment. image See the highlighted, that is my comment, the text above it is a quote to a previous comment. Can you please stop derailing this thread that is intended to assist people who are having an issue getting WSL to run. We are not here to discuss DNS.

UnknownFX02 commented 3 years ago

I also get this error when enable wslg

ivanjx commented 3 years ago

last time i got this i restarted windows explorer process from task manager and wsl worked again

HoussemNasri commented 3 years ago

Enabling Guarded Host solved my issue

PavelSosin-320 commented 3 years ago

Please, attach the recent WSL_Console_log from the User's home directory. It contains the Linux kernel boot log, Distro boot log and P9 protocol startup messages. It is used by Explorer. If the file looks too big, at least everything that looks like error message.

tvvignesh commented 3 years ago

@pedrolamas Thanks. I did not have dockerd but I had this issue because of svchost->ShardAccess. Stopped it as you said and it worked 🎉

marohinmark commented 3 years ago

Solve "process exited with code 4294967295" , run netsh winsock reset as Administrator, then reboot your computer. The result like below:

❯ netsh winsock reset

Sucessfully reset the Winsock Catalog.
You must restart the computer in order to complete the reset.

Thanks. It worked for me on windows 11.

jahescobar commented 3 years ago

You can solve it, just restarting linux system: Without restarting your pc These simple commands will reboot WSL2 for you which usually resolves any problems:

Press Win + R

Type: services.msc Then: Find the service LXSSMANAGER in the list. Right-click it and select Restart.

sunxuejian567 commented 3 years ago

I'm solved this with:

DISM /online /disable-feature /featurename:VirtualMachinePlatform /norestart
DISM /online /disable-feature /featurename:Microsoft-Windows-Subsystem-Linux /norestart

Reboot, and then:

DISM /online /enable-feature /featurename:VirtualMachinePlatform /norestart
DISM /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /norestart

That worked for me!

stevegoossens commented 3 years ago

For me, killing SharedAccess service and restarting Docker did not help.

However, running wsl --terminate Ubuntu-20.04 fixed it instantly. I have no idea if any of the previous steps were prerequisites, but I believe not.

This also worked for me, without even needing to reboot

walfredocarneiro commented 3 years ago

Solve "process exited with code 4294967295" , run netsh winsock reset as Administrator, then reboot your computer. The result like below:

❯ netsh winsock reset

Sucessfully reset the Winsock Catalog.
You must restart the computer in order to complete the reset.

I erased the file %USERPROFILE%\.wslconfig and solve the problem.

dmitrobaranov commented 3 years ago

Solve "process exited with code 4294967295" , run netsh winsock reset as Administrator, then reboot your computer. The result like below:

❯ netsh winsock reset

Sucessfully reset the Winsock Catalog.
You must restart the computer in order to complete the reset.

I erased the file %USERPROFILE%\.wslconfig and solve the problem.

This worked for me after power outage shutdown of my system with VM running. I had this file manually created before to increase resource limits for VM

Source61 commented 3 years ago

None of these suggestions worked for me. This issue happened after I ran diskpart compact successfully without any errors or warnings. After that I've tried everything so far including wsl --terminate, restarting ICS services, killing svchost, DISM and netsh winsock reset :( I run Debian, but going to install Ubuntu and see if I can mount the vdisk, maybe repair or at least hopefully save some files.

Xoroxa commented 3 years ago

None of these suggestions worked for me. This issue happened after I ran diskpart compact successfully without any errors or warnings. After that I've tried everything so far including wsl --terminate, restarting ICS services, killing svchost, DISM and netsh winsock reset :( I run Debian, but going to install Ubuntu and see if I can mount the vdisk, maybe repair or at least hopefully save some files.

I just had this issue and in order to fix it use this guide: https://github.com/microsoft/WSL/issues/5092#issuecomment-811693007

ntucker commented 3 years ago

I fixed this by

  1. removing subsystem in add/remove programs,
  2. installing kernel 5.4.91 from https://www.catalog.update.microsoft.com/Search.aspx?q=wsl

That's the last working kernel 5.10 doesn't work. Unfortunately this keeps installing without my consent so I have to repeat the process every few days.

Source61 commented 3 years ago

None of these suggestions worked for me. This issue happened after I ran diskpart compact successfully without any errors or warnings. After that I've tried everything so far including wsl --terminate, restarting ICS services, killing svchost, DISM and netsh winsock reset :( I run Debian, but going to install Ubuntu and see if I can mount the vdisk, maybe repair or at least hopefully save some files.

I just had this issue and in order to fix it use this guide: #5092 (comment)

Unfortunately this didn't work for me. It found a partition, but not a filesystem, fsck didn't help, so I gave up, deleted the VM, and installed a new one. This time I've setup automatic daily backup with a backup.sh script that goes to my C drive and another bash script to install all the packages I need to install on a fresh VM in case this happens again. I feel like the good thing about disk failures and VM corruptions (these kind of things has happened a fair bit to me) is that you slowly learn to make better backup systems and not be so sloppy and lazy that you don't do any of it since nothing's gone wrong.... yet.

Here's my simple script in case anyone wants it (keep in mind I haven't done any error checking or validation here, you're expected to call tar with at least two arguments (filename [without .tar.gz] and at least 1 filepath), it also doesn't check if any of the command fails, it just writes everything to backup.log, it's your responsibility to check the log file once in a while):

#!/bin/bash

tar() {
    echo "/bin/tar cfz $dst/$1.tar.gz ${@:2}"
    echo "* Running /bin/tar cfz $dst/$1.tar.gz ${@:2} 2>&1" >> ~/backup.log
    cmdoutput=`/bin/tar cfz $dst/$1.tar.gz ${@:2} 2>&1`
    ret=$?
    output="-> $cmdoutput"
    echo $output >> ~/backup.log
    return $ret
}
dst="/mnt/c/path/to/backup/dir/`date +%F`"
if [ ! -d $dst ]; then
    mkdir $dst
fi

echo "[`date +'%F %T'`] Running backup:" >> ~/backup.log

# Start backup
tar example ~/example1.txt ~/example2.txt
tar another ~/another1.txt ~/another2.txt ~/another3.txt
# End backup

echo "" >> ~/backup.log
googya commented 3 years ago

I'm solved this with:

DISM /online /disable-feature /featurename:VirtualMachinePlatform /norestart
DISM /online /disable-feature /featurename:Microsoft-Windows-Subsystem-Linux /norestart

Reboot, and then:

DISM /online /enable-feature /featurename:VirtualMachinePlatform /norestart
DISM /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /norestart

this time, this method worked for my situation

abdelhousni commented 2 years ago

@pedrolamas It worked for me too, I don't use Docker much so I removed it. I'll reinstall it and try again later tonight.

the same for me, removing Docker-desktop solved it. thanks

scootz commented 2 years ago

@abdelhousni Confirmed. Removing Docker Desktop fixed my issue as well.

andrei9669 commented 2 years ago

I had this issue after I switched CPU and MB. I solved it by enabling CPU virtualization in BIOS

sinanbekar commented 2 years ago

6377

I just tried to open vhdx file in C:\Users\TrueAlex\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu20.04onWindows_79rhkp1fndgsc\LocalState and my Ubuntu isn't working anymore :( even after reboot.

I'm solved this with:

DISM /online /disable-feature /featurename:VirtualMachinePlatform /norestart
DISM /online /disable-feature /featurename:Microsoft-Windows-Subsystem-Linux /norestart

Reboot, and then:

DISM /online /enable-feature /featurename:VirtualMachinePlatform /norestart
DISM /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /norestart

This didn't work for me.

However,


wsl --shutdown
diskpart
select vdisk file="C:\Users\user\AppData\Local\Packages\CanonicalGroupLimited.UbuntuonWindows....\LocalState\ext4.vhdx"
attach vdisk readonly
# you can see already attached message
detach vdisk
exit

this solved without losing data. Do not forget to replace file path.

miralayipouya commented 2 years ago

I had a customer's VPN client installed on my machine (Cisco AnyConnect VPN), the customer's installation package also installed dnscrypt. Uninstalling this has resolved the issue on my machine, confirming other threads that indicate the issue is usually related to network issues... particularly port 53.

I had a DNS Server on my system which disabling it solved the issue! You saved me in a way that no one else could! thanks for the guidance. Cheers!

jsutherl3 commented 2 years ago

I am facing the same error and have tried each of the previously mentioned potential solutions. However I have had no success. I believe some virtualization or Hyper-V settings got adjusted when I installed BlueStacks 5 but even after uninstalling, I have the same error.

Is there a list of settings that need to be adjusted for WSL to work properly? Could I potentially re-install WSL, or would that wipe out all the files I have on the Ubuntu 18.04 distribution?

UPDATE: I don't expect this to be too helpful but I just updated my OS to Windows 11 and no longer have any issues. I suspect whatever settings got changed were reset with the update.

lxg208 commented 2 years ago

I had the same issue and snoopy82481 method worked for me.

The cause for my case is that I automatically mount network drive by add following to /etc/fstab:

T: /mnt/t drvfs defaults 0 0

When the network share is not available, wsl got stuck. And this is why a new instance of wsl can start. I modified the entry to following and tested with when network share is available and is not available. It works for both scenarios.

T: /mnt/t drvfs defaults,nofail 0 0

Hope this can be useful to other people. I really think the nofail should be the default, there is no reason otherwise.

JackelynOliveira commented 2 years ago

After trying almost every solution suggested with no success, I uninstalled and installed everything again. Doing this apparently had some effect but then I was having another error code this time: 0x80370102. I did what was suggested on this issue and it finally worked!

Disco-Chef commented 2 years ago

Had the same issue when opening Windows Terminal on Ubuntu profile.

Tried terminating with wsl --shutdown with no luck. Then netsh winsock reset as root and reboot, no dice. Wanted to see if it was Windows Terminal issue or WSL issue, so I launched the Ubuntu app (not through the Windows Terminal, just the microsoft store app/shell). Started, no problem. Opened a new Windows Terminal on Ubuntu profile and suddenly it worked... 🤷‍♂️

jesfreitas commented 2 years ago

I did as @Disco-Chef and it worked.

SimonDanisch commented 2 years ago

I had to reset my BIOS and didn't realize that it disabled virtualization as well. With the windows terminal I just got this generic error, and after I tried most suggestions in this thread, I tried ubuntu directly and it immediately became clear (thanks @Disco-Chef).

From the various underlying issues that are related to this generic error, it seems clear that the main thing should be to improve the windows terminal error display! Some hint along the lines of "we currently don't forward any underlying errors, please check ubuntu terminal directly to see what's going on" would already go a long way.