Skip to content

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

Closed

Description

  • 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: #4105 (comment)

Activity

  1. andreluizgit commented on Jun 13, 2019

    @andreluizgit

    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

  2. benhillis commented on Jun 13, 2019

    @benhillis
    Member

    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!

  3. added
    wsl2
    on Jun 13, 2019
  4. OmriSama commented on Jun 13, 2019

    @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!

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

  5. steven-peralta commented on Jun 13, 2019

    @steven-peralta
    Author

    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

  6. benhillis commented on Jun 13, 2019

    @benhillis
    Member

    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.

  7. benhillis commented on Jun 13, 2019

    @benhillis
    Member

    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.
  8. andreluizgit commented on Jun 13, 2019

    @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

  9. lzlrd commented on Jun 13, 2019

    @lzlrd

    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.

  10. andreluizgit commented on Jun 13, 2019

    @andreluizgit

    He wants it in WSL2 format.

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

  11. lzlrd commented on Jun 13, 2019

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

  12. andreluizgit commented on Jun 13, 2019

    @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

  13. lzlrd commented on Jun 13, 2019

    @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

    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.

  14. andreluizgit commented on Jun 13, 2019

    @andreluizgit

    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

  15. 136 remaining items

  16. steven-peralta commented on Sep 16, 2019

    @steven-peralta
    Author

    I can confirm Ben Hillis (@benhillis) that using the default HOSTS file as of %WinDir%\System32\drivers\etc (https://support.microsoft.com/en-us/help/972034/how-to-reset-the-hosts-file-back-to-the-default) has got WSL2 working for me.

    Seems this is supported by others below too.

    Background info:
    My hosts file was an older version of https://raw.githubusercontent.com/EnergizedProtection/block/master/extensions/porn-lite/formats/hosts-ipv6.txt.

    I guess one of the following is what kills WSL2:

    127.0.0.1 localhost
    127.0.0.1 localhost.localdomain
    127.0.0.1 local
    255.255.255.255 broadcasthost
    ::1 localhost
    ::1 ip6-localhost
    ::1 ip6-loopback
    fe80::1%lo0 localhost
    ff00::0 ip6-localnet
    ff00::0 ip6-mcastprefix
    ff02::1 ip6-allnodes
    ff02::2 ip6-allrouters
    ff02::3 ip6-allhosts
    0.0.0.0 0.0.0.0
    

    Thanks Skye19 and Christian Denat (@chdenat) for the idea. Steven Peralta (@steven-peralta) since this is your issue, you might wanna take a look here.

    Thanks for the information. I've since dropped out of receiving Insider builds and have reinstalled Windows 10 on my PC, but I believe I did have a custom hosts.txt file for ad-blocking before I did all of that.

  17. KerberosMorphy commented on Sep 19, 2019

    @KerberosMorphy

    Hi there!, I had really hard time to set WSL2, at each update I had retry without success and look back to this issues to see any improvement.
    But thanks to all of you! I would finally be able to use Docker with WSL2!

  18. chdenat commented on Sep 19, 2019

    @chdenat

    Glad to have open the door ;)

  19. hsmyers commented on Sep 19, 2019

    @hsmyers
  20. zyazhb commented on Sep 23, 2019

    @zyazhb

    TNX for information hosts is the causion! DELETE hosts fix this.

  21. benhillis commented on Oct 3, 2019

    @benhillis
    Member

    Fixed in 18995.

  22. lelayf commented on Nov 6, 2020

    @lelayf

    I had manually added some remote hosts to /etc/hosts under Ubuntu WSL2 and that seems to have created the same problem when those hosts ceased to exist and their DNS resolution failed. Deleting the hosts file under System32 as described above and a restart solved it.

  23. MarkSCQ commented on Nov 19, 2020

    @MarkSCQ

    I dont know why, it seems restart solves everything 😆

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

Metadata

Metadata

Labels

wsl2

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions