4

On Windows 10 npm suddenly can't get internet access in any terminal (Powershell, cmd, wsl, or the terminal in VS Code) when I'm connected to the internet via a mobile phone's hotspot. This was working for years and I don't see what the catalyst was to break it (I hadn't installed anything new or changed any internet settings). If I go to any browser, the internet works fine, it's just from the terminal that it doesn't work. I've tried totally deactivating the firewall and that doesn't fix it. I did run a wsl --shutdown command a few days before noticing this, but I don't see how that would have such a sweeping impact even outside of wsl. All terminals also connect to the internet normally when over wifi that isn't from a cellphone hotspot. After the problem started, I updated Windows to the latest version of Windows 10 but that didn't do anything. The cellphone I'm using is a Pixel4A.

Update: I can still pip install packages but I can't use npm for anything that requires the internet. For example, running npm outdated returned this:

...
22 verbose Windows_NT 10.0.19042
23 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "outdated"
24 verbose node v12.18.4
25 verbose npm  v6.14.6
26 error code ECONNRESET
27 error errno ECONNRESET
28 error network request to http://registry.npmjs.org/express failed, reason: read ECONNRESET
29 error network This is a problem related to network connectivity.
29 error network In most cases you are behind a proxy or have bad network settings.
29 error network
29 error network If you are behind a proxy, please make sure that the
29 error network 'proxy' config is set properly.  See: 'npm help config'

I don't think I'm behind a proxy but I do get this error when I run an app I'm building locally in the browser (the app still builds):

Proxy error: Could not proxy request /favicon.ico from localhost:3000 to http://localhost/.

This is what nslookup returns in cmd and powershell:

PS C:\> nslookup google.com
Server:  UnKnown
Address:  192.168.13.64

Non-authoritative answer:
Name:    google.com
Addresses:  2607:f8b0:4006:80a::200e
          142.250.80.14
Alex
  • 2,154
  • 3
  • 26
  • 49
  • 1
    What does nslookup google.com from your terminal says? It's possible that the DNS config is borked up, but your browser pick different settings (could be from DNS over HTTPS auto upgrade or an extension) so they still work – Martheen Mar 04 '21 at 05:16
  • What if you disable [metered connection](https://support.microsoft.com/en-us/windows/metered-connections-in-windows-10-7b33928f-a144-b265-97b6-f2e95a87c408)? – CodeCaster Mar 04 '21 at 08:06
  • 1
    Try curl -Uri:"http://registry.npmjs.org/express" on PS – Martheen Mar 04 '21 at 08:21
  • @CodeCaster the hotspot connection is not metered. – Alex Mar 04 '21 at 16:32
  • @Martheen the curl command exited with code 200 so I think that was successful, but it didn't change anything. – Alex Mar 04 '21 at 16:32
  • While tethered, can you specifically go to the website http://registry.npmjs.org/express from a browser? I think that the Mobile carrier is specifically blocking the site. – HAL9256 Mar 09 '21 at 17:44
  • @HAL9256 yes I can view it from a browser while tethered. It looks like a big JSON object. – Alex Mar 09 '21 at 18:05
  • Hello, did you find a solution here? I'm having exact problem except over my home's wifi. npm just hangs and timesout, and my development servers cannot make and requests. Thank you. – rolias4031 Apr 19 '23 at 14:03

5 Answers5

0

It may be possible your carrier started enforcing a 'no tethering' rule that they likely have in their ToS.

It's really hard to say much more without looking into your network settings but judging by the fact your browser traffic is still fine I'd suspect some sort of proxy does indeed get injected into your pipeline: it can either be somehow pushed onto your windows host or be transparently handling all http traffic on the network.

I think one way to test whether this theory is true or not would be to stand up a VPN client on your phone and route all tethered traffic there.

timur
  • 14,239
  • 2
  • 11
  • 32
  • Thanks but using a vpn on my phone doesn't have any impact. – Alex Mar 08 '21 at 03:54
  • yeah, it might be a bit tricky. You could potentially look at apps that do all this anti-tethering package for you. I can't suggest any proved specifics but I remember seeing a few names pop up when looking around for details. – timur Mar 08 '21 at 04:37
  • 1
    Since I can connect to the internet from a browser when tethering, I don't think this is the issue. – Alex Mar 12 '21 at 20:41
0

You could attempt editing the hosts file to manually assign DNS entries and use Bluetooth tethering.

9pfs
  • 560
  • 5
  • 17
0

You can try first with a cache clean

$ npm cache clean --force 

I know it is not related, but in your situation is harmless, if this not work. Then, maybe you could use a mirror

$ npm config set registry https://registry.npm.taobao.org/

and use npm install

$ npm install your-lib-name

you can reset this later with npm set registry

$ npm set registry https://registry.npmjs.org/
Ruben Santana
  • 411
  • 5
  • 10
0

First of all, check a list of latest Windows updtating, any installed kb at this period? NO? try to load your OS in safe mode with Network supporting, is it solve problem and works in safe mode? NO? Check result of [ipconfig /all , route print, tracert google.com] by using mobile Accsess Point, and [ipconfig /all , route print, tracert google.com] by using Wi-fi Compare the results. Final and most hard, but 100% way.. load and install WireShark, set filter to sniff http, https and start internet connection in your shell, in what step it stucks?

FletcherF1
  • 167
  • 7
0

If you have Dynatrace installed, this program could be corrupting the normal npm working. After you uninstall Dynatrace, the problem might solve.

Also, doing a full scan for rootkits, spywares, virus, etc with different Antivirus, Anti-malware software's and cleaning what was found could help solve the issue.

Neha Jha
  • 291
  • 2
  • 9