5
ubuntu@ubuntu:~$ npm install -g yarn
npm ERR! code EHOSTUNREACH
npm ERR! errno EHOSTUNREACH
npm ERR! request to http://registry.npmjs.ord/yarn failed, reason: connect EHOSTUNREACH 104.16.22.35:80

I have gone through every other link about this error and I have 3 factors that are different to all of them and they are important because they were the solution to everyone else's problems. Links I have read and have not solved the issue:

Still I'm struggling.

  • Internet is stable and works
  • I can ping registry.npmjs.org and other sites
  • registry.npmjs.org isn't pointing to a local address

I have tried clearing proxy settings, I don't have proxy settings to try but is the only thing that it could be but I don't understand what to put there if needed (but considering the guides on how to clear it, they aren't required). I have no idea what to try as all of the solutions to every other instance does not apply to me.

Ubuntu 20.04.3 for Raspberry Pi

tripleee
  • 175,061
  • 34
  • 275
  • 318
dontfknow
  • 155
  • 8

1 Answers1

0

Problem

My setup: npm and pnpm on Ubuntu 22.04 LTS on a laptop

Worked for weeks without issue. Then suddenly I couldn't install anything. Example error messages from pnpm add -D vite:

 ERR_PNPM_META_FETCH_FAIL  GET https://registry.npmjs.org/vite: request to https://registry.npmjs.org/vite failed, reason: connect EHOSTUNREACH <redacted ipv6 address>

and

 WARN  GET https://registry.npmjs.org/fsevents error (EHOSTUNREACH). Will retry in 1 minute. 1 retries left.

Was able to browse to https://registry.npmjs.org/fsevents via web browser no problem. Had internet.

Also tried installing packages with npm. That didn't work either.

npm version 8.19.2

pnpm version 7.19.0

Solution

Connecting to a VPN fixed it. Don't know why.

Speculation: Maybe it has something to do with ipv6. Events leading up to the error: 1) Connected to a VPN for the first time (new computer). 2) Disconnected from the VPN (still had internet). 3) Error struck the first time I tried installing something from NPM after disconnecting from the VPN. 4) Re-connected to VPN; error gone.