Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Very slow network speed on WSL2 #4901

Open
carl-berg opened this issue Feb 16, 2020 · 375 comments
Open

Very slow network speed on WSL2 #4901

carl-berg opened this issue Feb 16, 2020 · 375 comments
Labels

Comments

@carl-berg
Copy link

carl-berg commented Feb 16, 2020

Windows build number: 10.0.19041.84
Dist: Ubuntu 18.04 LTS

I just installed WSL2 on my home computer for the first time and something i notice that i don't see on my work computer is that WSL2 has dramatically lower network speed (wget or git clone tested). Speeds on WSL seem to be about 10-20 kb/s wheras windows download speed seem to be correlating to my ISP spec of 100/10 Mbps or above.

@therealkenc
Copy link
Collaborator

Screencap speedtest-cli as a starting point.

$ sudo apt install speedtest-cli
$ speedtest-cli
[...]

image

@carl-berg
Copy link
Author

Okies, here's speedtest on windows, in the browser:
Speedtest_win

...and here's speedtest from wsl2:
Wpeedtest_wsl2

@acirulis
Copy link

Same here. Especially upload speed was drastically reduced - 36.61 -> 3.85 Mbit/s

@guilhermehrcosta
Copy link

Hi, same here. My download was drastrically reduced of 200Mbit/s to 2 Mbit/s. Is there a solution?

@AndrewGaspar
Copy link

I'm hitting this issue, as well. Very frustrating.

@kennethnipper
Copy link

I'm seeing same issue. Speedtest-cli in bash:
image

speedtest in Windows:
image

@tin-liu
Copy link

tin-liu commented Mar 14, 2020

Edit: After several reboots and adding the related folders as exceptions in Windows Defender as @jituanlin 's referred blog pointed out, and then tried removing the exceptions because I wanted to check which folder exception actually helped (so eventually theoretically equivalent to reboots-only, but who knows?), now in WSL Ubuntu Ver. 2 I have down = ~80 Mbit/s & up = ~4 Mbit/s. The upload is still about only 1/10 of the actual limit, but the download is up-to-standard now.

Also, the command speedtest is ~15 Mbit/s faster (download) than speedtest-cli for me.

Old comment:
Windows network faster than WSL Ubuntu Ver. 1 which faster than WSL Ubuntu Ver. 2 here:

  1. Windows Ookla on Web browser
    down ~88 Mbit/s
    up ~38 Mbit/s
  2. WSL Ubuntu Ver. 1 speedtest-cli
    down ~32 Mbit/s
    up ~4 Mbit/s
  3. WSL Ubuntu Ver. 2 speedtest-cli
    down ~3 Mbit/s
    up ~4 Mbit/s

Cheers

@jituanlin
Copy link

After follow this blog
My network/file access improve more than 5 times speed.

@rducom
Copy link

rducom commented Apr 8, 2020

Same here, really annoying. Disabling AV (defender) doesn't helps
image

@markgaze
Copy link

markgaze commented May 3, 2020

Same here. Getting about 7Mbit/s on WSL2 and 30+ in Windows.

Disabling Defender also made no difference for me either.

@Vildevil
Copy link

Vildevil commented May 15, 2020

Same here :
Windows and WSL :

  • Up 261mb/s
  • Down 248mb/s

WSL 2 :

  • Up 1.60mb/s
  • Down 0.08mb/s

@copeland3300
Copy link

copeland3300 commented May 15, 2020

Oddly, I'm getting decent results from the speedtest-cli, but things such as apt update are extremely slow, that is, less than a MB/s, where I'm used to seeing 30-40MB/s on my standard Ubuntu systems...

Speedtest results...

Retrieving speedtest.net configuration...
Testing from Verizon Fios (108.28.56.14)...
Retrieving speedtest.net server list...
Selecting best server based on ping...
Hosted by QTS Data Centers (Dulles, VA) [5.59 km]: 27.576 ms
Testing download speed................................................................................
Download: 427.07 Mbit/s
Testing upload speed......................................................................................................
Upload: 85.70 Mbit/s

apt update results

Get:1 http://security.ubuntu.com/ubuntu focal-security InRelease [107 kB]
Hit:2 http://archive.ubuntu.com/ubuntu focal InRelease
Get:3 http://archive.ubuntu.com/ubuntu focal-updates InRelease [107 kB]
Get:4 http://archive.ubuntu.com/ubuntu focal-backports InRelease [98.3 kB]
Get:5 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages [94.0 kB]
Get:6 http://archive.ubuntu.com/ubuntu focal-updates/universe amd64 Packages [30.5 kB]
Fetched 437 kB in 2s (197 kB/s)

@oliver-dungey
Copy link

Same issue here, dire network speed in WSL2. Performance with Linux or WSL is fine.

@aleled
Copy link

aleled commented May 30, 2020

I am experiencing the same

Speedteswt from WSL are poor compared to CMD

1

@mrorat
Copy link

mrorat commented May 30, 2020

Same here, Windows is about 60Mbps vs WSL2 14kbps !!!!

@arthurgeron
Copy link

I think it's useful to let people know that this doesn't happen to everyone, I'm getting my full speed here in WSL 2 on Windows 10 2004 (non Insider)
image

@didinele
Copy link

didinele commented Jun 2, 2020

Much more interesting for me!

On windows image

Over on my freshly intalled WSL2 image

Seems like download speed remained rather intact, however upload was heavily hit.

Windows 10 Enterprise version 2004, Ubuntu 18.04 LTS`

@rarora7777
Copy link

rarora7777 commented Jun 3, 2020

I'm seeing 249.94mbps down / 15.42mpbs up on Windows, which is pretty much what I expect from my ISP. On WSL2, sppedtest-cli shows 4.69mbps down / 3.29mbps up.

But apt and git performance in WSL2 is so much worse. I'm getting download speeds of 4–16 kbps on both.

I don't recall measuring network speed on WSL1, but such terrible performance would have been quickly noticed.
Edit: Just installed a WSL1 Ubuntu 20.04 LTS and I got 193.61 mbps down / 16.94 mbps up.

I'm on Windows 10 Enterprise version 2004 (build 19041.264) and Ubuntu 18.04 LTS that I recently upgraded to WSL2.

@BeErikk
Copy link

BeErikk commented Jun 4, 2020

Just FYI. I have experienced extremely slow network speed as well, but it seems to be a temporary issue. Perhaps a local network issue? Right now in WSL 1 (2004 not insider) I get:

speedtest-cli
Retrieving speedtest.net configuration...
Testing from AllTele (XX.XX.XX.XXX)...
Retrieving speedtest.net server list...
Selecting best server based on ping...
Hosted by A3 Allmänna IT - och Telekomaktiebolaget (Stockholm) [162.45 km]: 12.928 ms
Testing download speed................................................................................
Download: 124.83 Mbit/s
Testing upload speed......................................................................................................
Upload: 122.34 Mbit/s

@JennToo
Copy link

JennToo commented Jun 5, 2020

I was having a similar issue and found that switching from Wifi to Ethernet helped.
I don't really understand why, as speedtests over my Wifi are fine outside of WSL2. I suppose it's possible that the Ethernet driver is somehow interacting with WSL and/or HyperV better.

Ethernet NIC is a "Killer E2500 Gigabit"
WiFi is a "Killer Wireless n/a/ac 1535" (though the only thing it seemed to "Kill" was my network performance 😄)

@dvsmaxv
Copy link

dvsmaxv commented Jun 9, 2020

Hello friends,
I'm not good at English, But me too I faced the same issue and I tried so many time and finally I got one solution and here's the url: https://www.hitxp.com/articles/software/ubuntu-fix-slow-wireless-internet-connection-speed-upgrading-11-04-natty-narwhal/. With sample pic

Screenshot from 2020-06-09 22-05-31

@matze19999
Copy link

don't have the problem on surface pro x (arm64)

@mrorat
Copy link

mrorat commented Jun 10, 2020

It gets better... my speedtest today (Ethernet):
WSL2:
Download: 45.98 Mbit/s
Upload: 3.39 Mbit/s

Windows:
Download: 46.5 Mbit/s
Upload: 17.8 Mbit/s

@takizo
Copy link

takizo commented Jun 10, 2020

Hi all, I got the latest Windows 10 ver 2004 update. Switching from WSL1 to WSL2. I have the similar slow issue like you all had. But not particularly on the internet, it's more on Windows to Ubuntu via localhost access

Windows Version: 2004
Build: 19041.264
Ubuntu: 18.04.4

I run php development in WSL with Ubuntu 18.04.4, I have apache2, php7.2 and MariaDB running very well on WSL1

During development, I usually tunnel to my server to load ElasticSearch/Postgresql data, the tunnel is listen on localhost with respective port numbers.

I do not have connection problem when running in WSL1, the speed is tremendous fast. It's fast like the data is loading on my machine itself.

But when I switch to WSL2, I notice the connection is extremely slow. The initial loading took like 5-7 secs. Then the page would rendered. The hostname is mapped to 127.0.0.1, I've tried mapped on WSL2 Ubuntu private IP, the results are the same - Slow.

I've capture the video and sharing with you all.

Here is the video running on WSL1

https://www.youtube.com/watch?v=tNFtUUd2sG4

What I did was wsl --set-version Ubuntu 2, to upgrade the current Ubuntu distro to WSL2. Here is the video of the same development site running on WSL 2 (Please look at left bottom status bar)

https://www.youtube.com/watch?v=JFYgzMHf2RU

I've tried the comments on this thread, no luck getting it load fast like WSL 1. Hopefully this can be fixed,

I've switched back to WSL1 and the speed is back to normal. You may refer to the video below, the result is instance.

https://www.youtube.com/watch?v=9Q5Ors94lJM

@AlejandroAkbal
Copy link

AlejandroAkbal commented Dec 7, 2023

Just for people still looking for a complete solution

Create this file in C:\Users\YOURUSER\.wslconfig

[wsl2]

[experimental]
networkingMode=mirrored

And run wsl --shutdown in your terminal

Thats it, when you re-start your WSL distro, it should have the same speed as your Windows host

Read more about this here: https://learn.microsoft.com/en-us/windows/wsl/wsl-config#wslconfig

@nautics889
Copy link

In addition to @AlejandroAkbal 's answer, as far as i understood, running wsl without networkingMode=mirrored option (i. e. default) means your WSL will be behind NAT.

If the value is mirrored then this turns on mirrored networking mode. Default or unrecognized strings result in NAT networking.

@kernelPanic0x
Copy link

kernelPanic0x commented Dec 29, 2023

I had the same very frustrating problem but i think i got a work around. I used https://github.com/ChrisTitusTech/winutil to reset Winsock (Reset Networking). It is under Config > Reset Network. I am not 100% sure if it was this alone because i also completly removed WSL and Hypervisor from features list and reinstalled it also with this tool. But after this clean up and reinstall and a good old' reboot, everything worked magically. I also did wsl --update immediatly after reboot.

Maybe it helps someone!

@ericblade
Copy link

ericblade commented Jan 20, 2024

sooooo.... Fresh install of pretty much everything. Just upgraded to a 1.2Gbit down network link.

WSL version: 2.0.14.0
Kernel version: 5.15.133.1-1
WSLg version: 1.0.59
MSRDC version: 1.2.4677
Direct3D version: 1.611.1-81528511
DXCore version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
Windows version: 10.0.22631.3007

Windows: speeds ranging from 600mbit to 950mbit (i probably need to upgrade a switch between the network and myself to get over that)
WSL2: speeds ranging from 20mbit to 200mbit

Enabling mirrored networking mode doesn't seem to do anything except break my portforwards.

Per the WSL mirrored mode networking update doc, it indicates that that adds the ability to connect to the WSL VM from the LAN and to Windows servers from within the Linux VM. That already works without mirrored mode. Enabling mirrored mode causes everything to pretty much break, and if there is any speed up of networking, it's only very slight.

After doing a network reset and rebooting, I am more consistently getting the 200mbit speeds than the 20mbit speeds, but it's still pretty low speed in comparison. Probably legitimately averaging closer to 50mbit, rather than the 1Gbit i should be getting.

@SoniCoder
Copy link

netsh int ipv4 set interface "Wi-Fi" forwarding=enable

What is this magic? It fixed the awfully slow WSL 2 network connection.

it fixed the super slow speed on Firefox on WSL2 for me! I'm using an external Wi-Fi adapter

This worked for me

@chrisbennight
Copy link

netsh int ipv4 set interface "Wi-Fi" forwarding=enable

What is this magic? It fixed the awfully slow WSL 2 network connection.

it fixed the super slow speed on Firefox on WSL2 for me! I'm using an external Wi-Fi adapter

This worked for me

Same here - toggling sharing on the network interface is the only thing that works reliably for me. (by toggling, I mean sometimes I need to disable then re-enable sharing when wsl2 gets slow.

@jacksongnav
Copy link

netsh int ipv4 set interface "Wi-Fi" forwarding=enable

What is this magic? It fixed the awfully slow WSL 2 network connection.

it fixed the super slow speed on Firefox on WSL2 for me! I'm using an external Wi-Fi adapter

This worked for me

That immediately fixed it for me too.

@ericblade
Copy link

ericblade commented Feb 2, 2024

fwiw, after trying everything in this thread except network mode mirrored (which breaks WSL networking for me completely), still getting about 1/4 my total bandwidth in WSL at most, and 1/4 that inside WSL2 docker containers. docker/for-win#8590

@yjxiong
Copy link

yjxiong commented Feb 8, 2024

gets better... my speedtest today (Ethernet): WSL2: Download: 45.98 Mbit/s Upload: 3.39 Mbit/s

Windows: Download: 46.5 Mbit/s Upload: 17.8 Mbit/s

netsh int ipv4 set interface "Wi-Fi" forwarding=enable

What is this magic? It fixed the awfully slow WSL 2 network connection.

it fixed the super slow speed on Firefox on WSL2 for me! I'm using an external Wi-Fi adapter

This works for me, too. To be specific:

  1. in a Windows terminal, I used ipconfig to find the interface name of my WIFI adapter. "Wi-Fi 2" in my case.
  2. In a windows terminal I ran with the administrator privilege, I typed the command
    netsh int ipv4 set interface "Wi-Fi 2" forwarding=enable. The response is OK..

The download speed immediately improves in my WSL2 Ubuntu 22. I think the issue is probably with my using Wi-Fi, which is not properly forwarded to the container.

@mikhailgarber
Copy link

netsh int ipv4 set interface "Wi-Fi" forwarding=enable

worked for me

@TryZeroDiv
Copy link

It works very good for me too, thank you. I'm very happy :D

I just want to note that enabling IP forwarding on your device can introduce potential security risks, including making your device a pass-through for possibly malicious traffic. It's important to proceed with a clear understanding of these risks and to take appropriate security measures.

@ericblade
Copy link

Interestingly -- GUI apps (at least, google-chrome) don't seem to be restricted. google-chrome I can hit 1.1gbps at fast dot com. at speedtest dot net, 900mbps. through speedtest-cli, max 250-300mbps.

Make it make sense, please. :D

@pkgears
Copy link

pkgears commented Feb 20, 2024

I had the same very frustrating problem but i think i got a work around. I used https://github.com/ChrisTitusTech/winutil to reset Winsock (Reset Networking). It is under Config > Reset Network. I am not 100% sure if it was this alone because i also completly removed WSL and Hypervisor from features list and reinstalled it also with this tool. But after this clean up and reinstall and a good old' reboot, everything worked magically. I also did wsl --update immediatly after reboot.

Maybe it helps someone!

This worked for me

@kaziabidazad
Copy link

Tange

This should be the accepted answer.
And why is it not the default value?

@ericblade
Copy link

Tange

This should be the accepted answer. And why is it not the default value?

.... because if resetting the nameserver works for you, then probably your dns is misconfigured in windows. but also, dns is irrelevant to this problem.

@pacorreia
Copy link

About this issue, I faced it as well when using the mirrored mode, but not when using NAT.

So why in my case?
I disabled the automatic update of resolv.conf because wanted to set my own dns servers (on NAT mode), and also to solve VPN issues.

Then mirrored mode came into place, and damn, was weird, but after while it made, mirrored is supposed to share the same IP/interface, meaning also same DNS, but I was using a static config and preventing WSL from automatically updating it.

I've tested setting my nameserver to my local router, and worked like a charm and as expected.
Then reset the resolv.conf file, allowed the automatic updating, and it also worked.

So to wrap up, to add to the checklist, verify if:

  • You've disabled automatic update of /tc/resolv.conf (edit your /etc/wsl.conf), and enable and restart wsl
  • You're using a nameserver poiting to the internal NAT gateway (from you were using NAT mode) and update it to google or the one in your local network

Hope it helps other lost souls out there

@awcator
Copy link

awcator commented Mar 21, 2024

If you have bridged connections with the WSL adapter and your WIFI adapter, it will also slow down. I had to delete the bridge adapter.

@ericblade
Copy link

so... i think we might have a flaw in speedtest apps. Speedtest cli consistently gets 300mbps or less for me, while speedtest in browser consistently is punching 900mbps now.

Also, Docker Desktop has an absolute speedcap of 100mbps, it seems.

@falexbr
Copy link

falexbr commented Mar 29, 2024

I had very slow upload speeds on WSL2 and figured out that my problem was with my wifi adapter being used as an External Network on Hyper-V Virtual Switches. I just deleted the switch and got full upload speed again.

@micksatana
Copy link

micksatana commented May 1, 2024

I previously have the experimental mirrored networking mode on as well, but it still require to have the Real-time protection disabled to be fast. Appends this into C:\Users\YOURNAME\.wslconfig

[experimental]
networkingMode=mirrored

Temporary disable Windows Defender > Virus & threat protection > Manage settings > Real-time protection works for me. The speed goes up rights away.

More permanent solution would be setting up Dev Drive and have WSL2 on Dev Drive (I don't know how to do that at the moment), probably need to wait for microsoft/devhome#748

@s0kil
Copy link

s0kil commented May 4, 2024

Just for people still looking for a complete solution

Create this file in C:\Users\YOURUSER\.wslconfig

[wsl2]

[experimental]
networkingMode=mirrored

And run wsl --shutdown in your terminal

Thats it, when you re-start your WSL distro, it should have the same speed as your Windows host

Read more about this here: https://learn.microsoft.com/en-us/windows/wsl/wsl-config#wslconfig

This also fixed slow WSL2 downloads for me.

@ericblade
Copy link

ericblade commented May 5, 2024

Since the latest WSL2 update, I'm pulling in 400-500mbps pretty consistently. However, in Windows, I'm pulling 2Gbps. I'm also no longer throttled to 100mbps total in docker-desktop

@geraldoam
Copy link

Just for people still looking for a complete solution

Create this file in C:\Users\YOURUSER\.wslconfig

[wsl2]

[experimental]
networkingMode=mirrored

And run wsl --shutdown in your terminal

Thats it, when you re-start your WSL distro, it should have the same speed as your Windows host

Read more about this here: https://learn.microsoft.com/en-us/windows/wsl/wsl-config#wslconfig

this one work for me, thank u

@neongoblin69
Copy link

Just for people still looking for a complete solution

Create this file in C:\Users\YOURUSER\.wslconfig

[wsl2]

[experimental]
networkingMode=mirrored

And run wsl --shutdown in your terminal

Thats it, when you re-start your WSL distro, it should have the same speed as your Windows host

Read more about this here: https://learn.microsoft.com/en-us/windows/wsl/wsl-config#wslconfig

Thank you very much, it helped. One question though, how did you find it ? Is it mentioned in docs or smth ?

@joaolucaswork
Copy link

After follow this blog My network/file access improve more than 5 times speed.

This works well for me.

@hitzhangjie
Copy link

hitzhangjie commented May 29, 2024

I see this problem, too. None of the suggestions mentioned above directly solves my problem, but it give me a right direction. In my case, my PC is installed an enterprise IT management software, it installed a virtual network adaptor, which supports higher network throughput than windows provided default, but it doesn't work well with WSL. So I just disable the feature, then problem solved.

@televators
Copy link

Tangentially related: it was taking my WSL really long to reach any DNS server, so I changed /etc/resolv.conf's value to 8.8.8.8 which massively sped up how long it took to find links. Hope this helps some of you.

Worked for me as well. Notice for future people edit it with nano under sudo nano /etc/resolv.conf also here line you need to add nameserver 8.8.8.8 and comment other one with namespace

Holy $#*!
I've wrestled with this issue for so long and could never get any improvement. Just updated this on mine and my WSL2 speedtest went from 0.1Mbps to 15Mbps, with ping under 50ms. The biggest issue for me has been the latency. Doing anything from WSL2 had a consistent latency of like 10–60 seconds, and my local dev projects would be impossible to use correctly since basically any API calls timed out 100% of the time.

I had updated host to use 1.1.1.1 but saw no difference. Didn't think about updating the DNS for Ubuntu itself, as I subconsciously presumed it would use the host's config for some reason.
Thank you thank you thank you.

PSA: Just editing /etc/resolv.conf won't last since it usually gets overwritten on reboot, so you'll need to look into the proper way to permanently set your DNS depending on what distro and network manager and all that jazz.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests