WSL: Node.js and NPM network dramatically slow
Windows Build Number
Windows 11 Pro 21H2 Build: 22000.100
WSL Version
- WSL 2
- WSL 1
Kernel Version
Kernel version: 5.10.43
Distro Version
Ubuntu 20.04
Other Software
I have Ubuntu, Docker (v20.10.7), WSL 2 installed in my system.
I am using nvm with node.js (tried different versions still the same results)
Repro Steps
Cloned my fresh repo.
npm install - might pass and actually install.
Whenever I want to install an additional package - it might take forever to install.
Expected Behavior
Should run smoothly, without a long time-consuming.
Actual Behavior
I have dramatically slow network speed while working with Node.js and NPM.
- Request made from Node.js app - randomly are slow, unstable, timeouts
- npm install might take forever
I have to cancel and run npm install again, and if I am lucky - all packages will be installed, otherwise, I have to cancel and run again.
I am unsure why cache revalidation takes so much time

Diagnostic Logs
I ran npm install --verbose
Here 24 mins duration highlighted, so I just canceled.

About this issue
- Original URL
- State: open
- Created 5 years ago
- Reactions: 29
- Comments: 50 (1 by maintainers)
@ssalbdivad Hi, Please try the following in your WSL
Then reboot and check if it works for you 😃 For me, it looks like solved. Did 4 reboots - works as expected.
Reopening this to track this issue.
I think that’s a workaround but not a solution. because out-of-the-box WSL doesn’t work as expected and requires manual manipulations.
IPv6 was also the root cause for me as well. This answer resolved it for me without having to fully disable IPv6: https://askubuntu.com/a/1200257
These were the last 4 lines in the file.
Closing, due to solution.
Same problems. Win 11
Node is unusable because of this, TBH
I’m having the same issue as of today, really bizarre 🤷
I have also run into that issue and I’m still on Win 10 with WSL2 on kernel version 5.10.16. The workaround with resolv.conf brakes all DNS resolving so this is not a solution.
Will do. I’m back on native Ubuntu for now since I can’t reliably update my project’s dependencies.
Would be great if someone on the WSL team could take a look given that whatever set of circumstances causes this to happen effectively blocks node development on WSL, which I assume is one of its most popular applications.
If you somehow fix it, please reply in this thread. It really annoying issue…
In my case I did these, for an Existing project
The removal of package-lock worked like charm. 😃
Disabling IPv6 in the network adapter fixed instantly
Happened to me today on latest kernel. Luckily, the resolve.conf hack helped to resolve this issue.
I’m disappointed spending $2k+ on a Windows laptop instead of Mac.
Yeah I fixed the problem with wsl/node similarly but forgot to post here, sorry. My node was already under wsl but my projects were on the windows part. That’s why I had lags. Moved everything to wsl and lags vanished. Very strange though that this wsl-windows communication is so slow. I guess other lag issues might be due to hidden calls to windows part
FWIW I’ve experienced this issue several times and had given up on it.
I tried both changing
/etc/resolv.confand usinghttpinstead ofhttpsas described here.What worked for me was installing node inside WSL using n and adding the following to my
~/.bashrcfile (within WSL)(note the order of the path where I place
$N_PREFIX/binbefore the path)I had noticed that
which npmwas pointing to/mnt/c/Program Files/nodejs/npm...which led me to think it was running something on the windows side instead, which I assume adds some overhead when inside of WSL.What I would add to the conversation here is: What do you get when you run
which npmat the WSL bash prompt? If you get something like/mnt/c/Program Files/nodejs/npmthen try what I’ve described here.Still facing the same issue, MTU set to 1500 and tried the previous solution to delete the resolv.conf
It seem to have been an issue with too low MTU on my end.
List your interfaces from Windows:
Find the interface WSL is using, for me this was
"vEthernet (WSL)", and my MTU defaulted to 576. (if it’s higher for you it might be a different issue)Set the MTU on the interface to match your main interface, for me it was 1500:
(and maybe do a
wsl --shutdown?)Interesting, rollback brought me all the way back to 4.19.104, but I’m still having the same issue 🤨