WSL icon indicating copy to clipboard operation
WSL copied to clipboard

"An existing connection was forcibly closed by the remote host." error is presented when launching any WSL 2 distro

Open steven-peralta opened this issue 7 years ago • 152 comments

  • Your Windows build number: Microsoft Windows [Version 10.0.18917.1000]

  • What you're doing and what's happening: Trying to launch wsl.exe or bash throws an error message that states An existing connection was forcibly closed by the remote host.

    Microsoft Windows [Version 10.0.18917.1000]
    (c) 2019 Microsoft Corporation. All rights reserved.
    
    C:\Users\Steven>bash
    An existing connection was forcibly closed by the remote host.
    
    C:\Users\Steven>wsl
    An existing connection was forcibly closed by the remote host.
    
    C:\Users\Steven>

I've tried this with my converted Debian distro, as well as ArchWSL. I also tried to install Ubuntu but during setup after choosing my UNIX username the same error gets thrown.

  • What's wrong / what should be happening instead: The distro should be launching normally and I should be presented with a bash shell.

Log files: logs.zip

Edit (9/26/19): It appears that the number of entries in a modified hosts.txt is what is causing this issue at the moment. More information here: https://github.com/microsoft/WSL/issues/4105#issuecomment-531385551

steven-peralta avatar Jun 13 '19 02:06 steven-peralta

Me too. Same build 18917 and Debian, I converted it to Wsl version 2 but the Appx can't run after this convertion... Then I returned to Wsl version 1.

The issue can be the ext4.vhdx disk image that can't be open from Appx (Debian or Ubuntu) with Wsl2, before the linux files could be open via explorer with Wsl1.

Windows Insider forum : https://answers.microsoft.com/en-us/insider/forum/all/an-existing-connection-was-forcibly-closed-by-the-remote-host

andreluizgit avatar Jun 13 '19 02:06 andreluizgit

Thanks for filing. From the trace it looks like your instance is being terminated during creation. Does the following command work? If so can you give me the output? When you're in this state, can you look in task manager and see if there is a vmmem process running?

wsl.exe -u root -e dmesg

Thanks!

benhillis avatar Jun 13 '19 03:06 benhillis

Thanks for filing. From the trace it looks like your instance is being terminated during creation. Does the following command work? If so can you give me the output? When you're in this state, can you look in task manager and see if there is a vmmem process running?

wsl.exe -u root -e dmesg

Thanks!

That command doesn't work; I'm still getting the original An existing connection was forcibly closed by the remote host. message, but there is heightened Vmmem activity when I call this for sure (I tried calling it repeatedly and noticed the spike).

OmriSama avatar Jun 13 '19 05:06 OmriSama

Thanks for filing. From the trace it looks like your instance is being terminated during creation. Does the following command work? If so can you give me the output? When you're in this state, can you look in task manager and see if there is a vmmem process running?

wsl.exe -u root -e dmesg

Thanks!

Microsoft Windows [Version 10.0.18917.1000]
(c) 2019 Microsoft Corporation. All rights reserved.

C:\Users\Steven>wsl.exe -u root -e dmesg
An existing connection was forcibly closed by the remote host.

C:\Users\Steven>

This is what I see in task manager shortly after running that command image

The the first running vmmem process will stick around for a bit before disappearing, while the second one stays in its suspended state indefinitely

steven-peralta avatar Jun 13 '19 06:06 steven-peralta

Great thank you. It looks like the utility VM is still alive, it's the distro itself that is running into an issue. I'll dig into this a bit today.

benhillis avatar Jun 13 '19 13:06 benhillis

Would it be possible for somebody hitting the "An existing connection was forcibly closed by the remote host" issue to export your distribution and share the tar file? This will contain your entire root file system so if there is private information please send it to [email protected].

  1. wsl.exe --export DistroName FileName.tar
  2. Zip FileName.tar
  3. Email to [email protected], say it's for benhill, or upload and send me a link.

benhillis avatar Jun 13 '19 16:06 benhillis

Would it be possible for somebody hitting the "An existing connection was forcibly closed by the remote host" issue to export your distribution"

Can be with WSL 1 actived or must be only wsl2 ? I can run "wsl.exe --export DistroName FileName.tar" with my Debian in WSL1 ? and Then send to you

andreluizgit avatar Jun 13 '19 16:06 andreluizgit

Would it be possible for somebody hitting the "An existing connection was forcibly closed by the remote host" issue to export your distribution"

Can be with WSL 1 actived or must be only wsl2 ? I can run "wsl.exe --export DistroName FileName.tar" with my Debian in WSL1 ? and Then send to you

I think he wants it in WSL2 format.

lzlrd avatar Jun 13 '19 17:06 lzlrd

He wants it in WSL2 format.

Then only the ext4.Vhdx image converted (after change to WSL2) would be need

andreluizgit avatar Jun 13 '19 17:06 andreluizgit

He wants it in WSL2 format.

Then only the ext4.Vhdx image converted (after change to WSL2) would be need

Idk about you, but I'm experiencing it on a plain clean downloaded Ubuntu and Debian (and Kali) WSL instance so I'm not sure why it's needed at all.

lzlrd avatar Jun 13 '19 17:06 lzlrd

He wants it in WSL2 format.

Then only the ext4.Vhdx image converted (after change to WSL2) would be need

Idk about you, but I'm experiencing it on a plain clean downloaded Ubuntu and Debian (and Kali) WSL instance so I'm not sure why it's needed at all

I understood. Only problem with wsl2 is that it create a disk image and the Appx (Debian or Ubuntu) can't run

andreluizgit avatar Jun 13 '19 17:06 andreluizgit

He wants it in WSL2 format.

Then only the ext4.Vhdx image converted (after change to WSL2) would be need

Idk about you, but I'm experiencing it on a plain clean downloaded Ubuntu and Debian (and Kali) WSL instance so I'm not sure why it's needed at all

I understood. Only problem with wsl2 is that it create a disk image and the Appx (Debian or Ubuntu) can't run

If it helps, I don't think other optional features are interfering as I spent 15 mins switching between to see and no change. It's not due to other Hyper-V either.

lzlrd avatar Jun 13 '19 17:06 lzlrd

If it helps, I don't think other optional features are interfering as I spent 15 mins switching between to see and no change. It's not due to other Hyper-V either.

Me too. I tried enable & disable Hyper-V feature with Virtual Machine Platform enabled but This disk image "ext4.vhdx" Can't be Mounted

andreluizgit avatar Jun 13 '19 17:06 andreluizgit

wsl --export creates a tar regardless if the distro is WSL1 or WSL2. What I suspect is there's something in the root file system that /init does not like. The VM looks like it's being created and the distro is able to be converted, but launching the distro fails.

benhillis avatar Jun 13 '19 18:06 benhillis

Would it be possible for somebody hitting the "An existing connection was forcibly closed by the remote host" issue to export your distribution and share the tar file? This will contain your entire root file system so if there is private information please send it to [email protected].

1. wsl.exe --export DistroName FileName.tar

2. Zip FileName.tar

3. Email to [[email protected]](mailto:[email protected]), say it's for benhill, or upload and send me a link.

Hello

I sent you my distribution tarballs to [email protected]

steven-peralta avatar Jun 13 '19 18:06 steven-peralta

@steven-peralta - Awesome, thank you very much. Hopefully I am able to reproduce, if not I may need to add some more diagnostics...

benhillis avatar Jun 13 '19 18:06 benhillis

I can't email my distro tarball because it's 600+MB

Also why can't we see the VM in Hyper-V Manager?

OmriSama avatar Jun 14 '19 01:06 OmriSama

Would it be possible for somebody hitting the "An existing connection was forcibly closed by the remote host" issue to export your distribution and share the tar file? This will contain your entire root file system so if there is private information please send it to [email protected].

  1. wsl.exe --export DistroName FileName.tar
  2. Zip FileName.tar
  3. Email to [email protected], say it's for benhill, or upload and send me a link.

Hello

I sent you my distribution tarballs to [email protected]

xlong0408 avatar Jun 14 '19 05:06 xlong0408

I can't email my distro tarball because it's 600+MB

Also why can't we see the VM in Hyper-V Manager?

Use mega.nz or something similar.

It’s not a traditional VM and it’s using a different platform (Virtual Machine Platform) which is the third? platform for Hyper-V virtualisation in Windows as you can see in Control Panel > Programs > Manage Optional Features. The other two are default Hyper-V (the one you see in the manager) and Hypervisor Platform (Android emulator uses this but doesn’t appear in manager too).

lzlrd avatar Jun 14 '19 06:06 lzlrd

I can't email my distro tarball because it's 600+MB Also why can't we see the VM in Hyper-V Manager?

Use mega.nz or something similar.

It’s not a traditional VM and it’s using a different platform (Virtual Machine Platform) which is the third? platform for Hyper-V virtualisation in Windows as you can see in Control Panel > Programs > Manage Optional Features. The other two are default Hyper-V (the one you see in the manager) and Hypervisor Platform (Android emulator uses this but doesn’t appear in manager too).

The problem is that the Appx (Ubuntu or Debian) can't open this new VM (image disk ext4.vhdx) because the App was built to execute the root files with NT filesystem

more users with similar issues : https://github.com/microsoft/WSL/issues maybe would be good to suspend the release of wsl2 for this moment

andreluizgit avatar Jun 14 '19 14:06 andreluizgit