You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
apt-get update/upgrade/install downloads packages at unacceptably slow speeds. #2477
Your Windows build number: Microsoft Windows [Version 10.0.15063]
What you're doing and what's happening: sudo apt-get update && sudo apt-get upgrade -y downloads packages at less that 100 kB/s.
What's wrong / what should be happening instead: apt should fetch packages much faster. My internet speed is 100 down / 10 up, on a bare-metal Linux installation or VirtualBox instance, apt is blazing fast. Packages are downloaded at upwards of 1024 kB/s.
Strace of the failing command, if applicable: n/a
Reacted by Philipp Rudloff, Mohamed Sharaf, Anton Rudeshko, Miyuru, Mike, Alex Telon, Matthew Lake, Nícolas Iensen, Abbas Yadollahi, Roman Hrokholskyi and 51 more
Audrey Drake (@RalphORama) - Thanks for your post. We are aware that WSL networking perf is not at par with native Linux, but should not be unbearable. There are plans to improve the WSL n/w perf. I am not sure if uninstall/reinstalling will change much here for you.
Reacted by Brian Peiris, Aslam Hadi H and Michael Sander
Reacted by Mike, Jamie Smith, Imre Ardelean, Arath Jimenez, Bram Vanroy, Ethan, drew moore, omairio, Ilham F Putra, Victor Alves and 8 more
We are aware that WSL networking perf is not at par with native Linux
Yeah WSL might not be on par with Real Linux, but we're talking Phoronix-style quibbling not mass degradation. I get awful apt-get speeds like the OP sometimes too (measured kbs/sec on a mbps link), but best evidence seems to be it is on Canonical's end (or something in between). I get the same thing in my Ubunutu VM from time to time. I am not sure why this is, but I think (speculating) that sometimes you just get a redirect to an unlucky server.
Audrey Drake (@RalphORama)
Best thing to do would be take Ubuntu out as a variable. Use speedtest from WSL CLI like poppoppop (@gravcat) suggests and then visit their website on Windows, and see if there is a serious gap in performance.
$ sudo apt install speedtest-cli
$ speedtest-cli
Retrieving speedtest.net configuration...
Retrieving speedtest.net server list...
Testing from Skyway West (69.50.175.134)...
Selecting best server based on latency...
Hosted by Shaw Communications (Vancouver, BC) [28.08 km]: 28.778 ms
Testing download speed........................................
Download: 34.39 Mbit/s
Testing upload speed..................................................
Upload: 5.22 Mbit/s
If you see an orders-of-magnitude difference between Windows and WSL, report back because that would be good to know; it is always possible there is something unique going on with your setup.
I found that Windows Defender absolutely murders performance in WSL, especially tools like apt-get.
Try temporally disabling it and see if that improves it or not.
Reacted by Peng Liu, Austin, Jamie Kuppel, prakharbitspilani, snipeXZ, Jacob, matdecro, Vũ Chí Thành, 1s0n, Esteban Cano and 4 more
I found that Windows Defender absolutely murders performance in WSL, especially tools like apt-get.
Try temporally disabling it and see if that improves it or not.
this. Windows Defender really messes with I/O actions in WSL, not just with apt-get... adding scan exemptions does not seem to help much.
Reacted by Idofriedman, Daniel Långfors, Mariano and Esteban Cano
this. Windows Defender really messes with I/O actions in WSL
It does. But keep in mind, in the OP this was the 'Get' phase, which is literally just a curl of a .deb. 46.6 kilobytes per second on a 100Mbit/s downlink. Install phase I understand, sure. Windows Defender gets upset when thousands of little untrusted files start appearing from nowhere (from Defender's perspective) though its filesystem filter driver. But if it were Defender you should see the same slowdown on a bog standard curl from a fast server, and you don't; at least not to this degree. Couple that with the fact that turning Defender off doesn't help. So, something else. I could be wrong, because Defender is a ginormous black box that does who knows what, on or off. But I'm not seeing the causality here.
I reinstalled WSL as poppoppop (@gravcat) suggested, and installed speedtest-cli. After running speedtest-cli and visiting the speedtest website, it appears WSL only uses 5% of my available bandwidth, maximum (1.6 Mbit/s vs 36 Mbit/s). I believe I have Windows Defender disabled, and I don't think I have any other programs that interfere with I/O on my machine. I use Malwarebytes as my antivirus, which doesn't run in the background. I'll try creating a firewall rule for bash.exe and report back.
Update: Creating a firewall rule and switching to OpenDNS had no effect on apt's download speeds.
therealkenc - Thanks for the repro steps. I tracked this down to a directory rename failing due something that has a handle open to one of the directory's children. Unfortunately this is an NTFS limitation that I can't think of a workaround without NTFS supporting posix-style rename. I know they were looking at that at some point, but I'm not sure of the status.
I am also experiencing this issue, did the solution suggested by poppoppop (@gravcat) work for anyone?
I would hate to have to download the entire distro again at these below 100 kB/s speeds, so am reticent about attempting it.
Aymane Boumaaza (@Aymane11) I actually have a PowerShell script I use to do this automatically for all WSL instances. You will need an escalated PowerShell instance (Run as Admin).
############
# This script will add your WSL environments to the Windows Defender exclusion list so that
# realtime protection does not have an adverse effect on performance.
#
# You should be aware that this could make your system less secure. Use at your own risk.
# Note: This should be run from an administrative PowerShell prompt
############
# Find registered WSL environments
$wslPaths = (Get-ChildItem HKCU:\Software\Microsoft\Windows\CurrentVersion\Lxss | ForEach-Object { Get-ItemProperty $_.PSPath}).BasePath
# Get the current Windows Defender exclusion paths
$currentExclusions = $(Get-MpPreference).ExclusionPath
if (!$currentExclusions) {
$currentExclusions = ''
}
# Find the WSL paths that are not excluded
$exclusionsToAdd = ((Compare-Object $wslPaths $currentExclusions) | Where-Object SideIndicator -eq "<=").InputObject
# List of paths inside the Linux distro to exclude (https://github.com/Microsoft/WSL/issues/1932#issuecomment-407855346)
$dirs = @("\bin", "\sbin", "\usr\bin", "\usr\sbin", "\usr\local\bin", "\usr\local\go\bin")
# Add the missing entries to Windows Defender
if ($exclusionsToAdd.Length -gt 0) {
$exclusionsToAdd | ForEach-Object {
# Exclude paths from the root of the WSL install
Add-MpPreference -ExclusionPath $_
Write-Output "Added exclusion for $_"
# Exclude processes contained inside WSL
$rootfs = $_ + "\rootfs"
$dirs | ForEach-Object {
$exclusion = $rootfs + $_ + "\*"
Add-MpPreference -ExclusionProcess $exclusion
Write-Output "Added exclusion for $exclusion"
}
}
}
Hope this part helps everyone, though I had the above for I/O performance improvements, it had no impact on connection speeds.
However what I did find, and my tests are below, is that disabling Windows Defender Firewall (Internet rules) does resolve it for the speed test, fixes downloading files directly as well.
BUT I'm still not getting good speed in docker containers running tensorflow projects in Jupyter notebooks. 24M files are taking minutes, where they take seconds if I try them via WSL terminal directly or on Windows
I should clarify this is using Docker CLI as NVidia CUDA support on WSL as you know isn't supported via Docker Desktop containers. So I'm not sure how or if that plays into it.
Baseline: Speedtest from Windows)
WSL Before & After disabling Firewall
Next I need to figure out what needs to be unblocked to ensure this doesn't happen without leaving firewall off entirely.
Any thoughts on specifically what to unblock? Can't imagine port based rules will do. Not sure which application you could select to unblock either.
I'm wired to a 600Mb connection. This is the only thing that is slow:
I already switched connections, removed code-insiders completely, and reinstalled them.
The first reinstallation goes quick then, but with every upgrade I'm back to slowness?
Sven Groot (@SvenGroot) Solution works for me, Also remember to change security mirrors too, So completed command will be like: mirror="us.archive.ubuntu.com" && sudo sed -i "s/archive.ubuntu.com/$mirror/; s/security.ubuntu.com/$mirror/" /etc/apt/sources.list, Also not sure that is it good idea to change security mirrors or not.
I just installed WSL2 on my desktop.
I've completely turned off the windows defender and real-time protection, and tried several mirror servers in my country.
However, it never goes over 50kB/s.
What is the problem, seriously?
this solved my kali issue, I had to wsl --showdown from powershell and restart kali for this to work.
now I dunno how the ubuntu got generated, ubuntu was doing the same issue as kali, probably wsl --shutdown solved it?
anyway, that's the only change I did to my wsl, oh and I moved to WSL 1 as well
## Update
Apparently it's windows defender related issue, after putting it back on and restarting wsl downloads became very slow, so I had to deactivate realtime protection then wsl --shutdown for it to work.
I realized the issue for me was that antivirus ESET was blocking the traffic for WSL Ubuntu.
Unblocked by going to Setup --> Network --> Troubleshooting Wizard --> Unblock.
Hi folks, we have put out a new update that aims to address networking issues in WSL. In your .wslconfig file you can set experimental.networkingMode=mirrored, as well as some other key settings that should improve your network compatibility! Please try them out and let us know what you think.
Please note: You need to be on a Windows Insiders version to use the new networking settings (Any channel of Windows Insiders will do, including release preview). If you see the "These are not supported" messages it means that your current Windows version doesn't have support, and you will need to upgrade. These features will eventually be coming to Windows 11 22H2.
I realized the issue for me was that antivirus ESET was blocking the traffic for WSL Ubuntu. Unblocked by going to Setup --> Network --> Troubleshooting Wizard --> Unblock.
Activity
gravcat commentedon Sep 8, 2017
If there is nothing meaningful in the environment and you don't mind completely destroying it, try the following in an elevated command prompt:
lxrun /uninstall /full /ylxrun /installSee if the problem persists if you completely redeploy the environment.
sunilmut commentedon Sep 8, 2017
Audrey Drake (@RalphORama) - Thanks for your post. We are aware that WSL networking perf is not at par with native Linux, but should not be unbearable. There are plans to improve the WSL n/w perf. I am not sure if uninstall/reinstalling will change much here for you.
gravcat commentedon Sep 8, 2017
my network speeds are fine and maxing out my link speed on
Microsoft Windows [Version 10.0.15063]therealkenc commentedon Sep 8, 2017
Yeah WSL might not be on par with Real Linux, but we're talking Phoronix-style quibbling not mass degradation. I get awful
apt-getspeeds like the OP sometimes too (measured kbs/sec on a mbps link), but best evidence seems to be it is on Canonical's end (or something in between). I get the same thing in my Ubunutu VM from time to time. I am not sure why this is, but I think (speculating) that sometimes you just get a redirect to an unlucky server.Audrey Drake (@RalphORama)
Best thing to do would be take Ubuntu out as a variable. Use speedtest from WSL CLI like poppoppop (@gravcat) suggests and then visit their website on Windows, and see if there is a serious gap in performance.
If you see an orders-of-magnitude difference between Windows and WSL, report back because that would be good to know; it is always possible there is something unique going on with your setup.
Aerocatia commentedon Sep 9, 2017
I found that Windows Defender absolutely murders performance in WSL, especially tools like apt-get.
Try temporally disabling it and see if that improves it or not.
heldchen commentedon Sep 9, 2017
this. Windows Defender really messes with I/O actions in WSL, not just with
apt-get... adding scan exemptions does not seem to help much.therealkenc commentedon Sep 9, 2017
It does. But keep in mind, in the OP this was the 'Get' phase, which is literally just a
curlof a.deb. 46.6 kilobytes per second on a 100Mbit/s downlink. Install phase I understand, sure. Windows Defender gets upset when thousands of little untrusted files start appearing from nowhere (from Defender's perspective) though its filesystem filter driver. But if it were Defender you should see the same slowdown on a bog standardcurlfrom a fast server, and you don't; at least not to this degree. Couple that with the fact that turning Defender off doesn't help. So, something else. I could be wrong, because Defender is a ginormous black box that does who knows what, on or off. But I'm not seeing the causality here.RalphORama commentedon Sep 9, 2017
I reinstalled WSL as poppoppop (@gravcat) suggested, and installed
speedtest-cli. After runningspeedtest-cliand visiting the speedtest website, it appears WSL only uses 5% of my available bandwidth, maximum (1.6 Mbit/s vs 36 Mbit/s). I believe I have Windows Defender disabled, and I don't think I have any other programs that interfere with I/O on my machine. I use Malwarebytes as my antivirus, which doesn't run in the background. I'll try creating a firewall rule forbash.exeand report back.Update: Creating a firewall rule and switching to OpenDNS had no effect on apt's download speeds.
benhillis commentedon Oct 5, 2017
therealkenc - Thanks for the repro steps. I tracked this down to a directory rename failing due something that has a handle open to one of the directory's children. Unfortunately this is an NTFS limitation that I can't think of a workaround without NTFS supporting posix-style rename. I know they were looking at that at some point, but I'm not sure of the status.
DarkIlluminatus commentedon Jan 27, 2018
I am also experiencing this issue, did the solution suggested by poppoppop (@gravcat) work for anyone?
I would hate to have to download the entire distro again at these below 100 kB/s speeds, so am reticent about attempting it.
leandrocrs commentedon Jan 27, 2018
Just turn off Windows Defender Real-time protection.
Add WSL folder and apt process in exclusion list will not work.
You should to completely disable real-time protection, reboot and will see how fast it will be
DarkIlluminatus commentedon Jan 28, 2018
Garry050 commentedon Feb 22, 2018
same here.
speedtest: both good speed (download: 70-90Mbps)
apt: always 30-300kb/s (ftp.jaist.ac.jp)
Using ESET Internet Security 11. no help disable anti-virus.
16299.214
66 remaining items
danieliser commentedon Jan 31, 2021
Aymane Boumaaza (@Aymane11) I actually have a PowerShell script I use to do this automatically for all WSL instances. You will need an escalated PowerShell instance (Run as Admin).
danieliser commentedon Jan 31, 2021
Hope this part helps everyone, though I had the above for I/O performance improvements, it had no impact on connection speeds.
However what I did find, and my tests are below, is that disabling Windows Defender Firewall (Internet rules) does resolve it for the speed test, fixes downloading files directly as well.
BUT I'm still not getting good speed in docker containers running tensorflow projects in Jupyter notebooks. 24M files are taking minutes, where they take seconds if I try them via WSL terminal directly or on Windows
I should clarify this is using Docker CLI as NVidia CUDA support on WSL as you know isn't supported via Docker Desktop containers. So I'm not sure how or if that plays into it.
Baseline: Speedtest from Windows)

WSL Before & After disabling Firewall

Next I need to figure out what needs to be unblocked to ensure this doesn't happen without leaving firewall off entirely.
Any thoughts on specifically what to unblock? Can't imagine port based rules will do. Not sure which application you could select to unblock either.
danieliser commentedon Jan 31, 2021
I have narrowed the docker issue as well now. Seems to be a bottleneck due to using a WiFi connection.
Switching to a wired connection and WSL2 -> Docker CE containers for tensorflow with GPU support will now download using the entire connection.
No idea why that is. Haven't been able to find any info on why docker has issues with wifi.
SanderElias commentedon Jun 18, 2021
I'm wired to a 600Mb connection. This is the only thing that is slow:

I already switched connections, removed code-insiders completely, and reinstalled them.
The first reinstallation goes quick then, but with every upgrade I'm back to slowness?
Arian8j2 commentedon Aug 20, 2021
Sven Groot (@SvenGroot) Solution works for me, Also remember to change security mirrors too, So completed command will be like:
mirror="us.archive.ubuntu.com" && sudo sed -i "s/archive.ubuntu.com/$mirror/; s/security.ubuntu.com/$mirror/" /etc/apt/sources.list, Also not sure that is it good idea to change security mirrors or not.sbin-github commentedon Oct 12, 2021
I just installed WSL2 on my desktop.
I've completely turned off the windows defender and real-time protection, and tried several mirror servers in my country.
However, it never goes over 50kB/s.
What is the problem, seriously?
j0e1an commentedon Oct 18, 2021
Work like a charm. Hate firewall just doing this.
emadha commentedon Feb 20, 2022
i copied the
/etc/resolve.conffrom ubuntu to kali's resolv.conf and it solved the problemthis solved my kali issue, I had to
wsl --showdownfrom powershell and restart kali for this to work.now I dunno how the ubuntu got generated, ubuntu was doing the same issue as kali, probably wsl --shutdown solved it?
anyway, that's the only change I did to my wsl, oh and I moved to WSL 1 as well
## UpdateApparently it's windows defender related issue, after putting it back on and restarting wsl downloads became very slow, so I had to deactivate realtime protection then
wsl --shutdownfor it to work.jhagege commentedon Feb 25, 2023
I realized the issue for me was that antivirus ESET was blocking the traffic for WSL Ubuntu.
Unblocked by going to Setup --> Network --> Troubleshooting Wizard --> Unblock.
craigloewen-msft commentedon Sep 19, 2023
Hi folks, we have put out a new update that aims to address networking issues in WSL. In your
.wslconfigfile you can setexperimental.networkingMode=mirrored, as well as some other key settings that should improve your network compatibility! Please try them out and let us know what you think.More info on this release and the changes can be found here in the blog post.
Please note: You need to be on a Windows Insiders version to use the new networking settings (Any channel of Windows Insiders will do, including release preview). If you see the "These are not supported" messages it means that your current Windows version doesn't have support, and you will need to upgrade. These features will eventually be coming to Windows 11 22H2.
meydiwahendra commentedon Sep 24, 2023
until now 2023, its still happening, this is servers relative issues !!
if you're an Asian, its easy to fix that problem, just copy and paste
see the different
mine running on 30mbps speed
DrorDvash commentedon Jan 1, 2024
Thanks! helped me too with ESET Internet Security
OneBlue commentedon May 14, 2024
Hi ! Please try the latest networking features that we've added in WSL. Those should greatly improve performance.
If the issue still remains, please reopen this issue.
bukowa commentedon Jun 26, 2024
Changing nameservers
Doesn't work for me.
The only thing that works is to change dns in
/etc/resolv.confBut
wslwill automatically change them after restart so...