I hope someone can help me troubleshoot this.
I was getting ETIMEDOUT
when installing packages with nvm 0.40.1
, node 22.14.0
& npm v10.9.2
. Tried multiple fixes that's across the internet and nothing worked! (downgrade, upgrade, cleanup, switching dns, installing pihole on a machine & using that for dns!)
I wrote a simple script with require('https')
to read and got a boatload of
Aggregate Error
with ETIMEDOUT
for IP4
& ENETUNREACH
for IP6
when trying to get any package page eg:
At same time, fetching google, microsoft, docker & many more works!
So I decided to try these
- VirtualBox 7 + Debian 12 + NAT networking = Not Working, same errors for npm & script
- VirtualBox 7 + Debian 12 + BRIDGE networking = WORKING both script & npm install
- Docker - tried multiple LTS v18/20/22 = All WORKING both script & npm install
NPM Config for Kubuntu & Debian VM (on docker is default ie similar with different path)
$ npm config ls
; node bin location = /home/USER/.nvm/versions/node/v22.14.0/bin/node
; node version = v22.14.0
; npm local prefix = /home/USER/works/nodetest
; npm version = 10.9.2
; cwd = /home/USER/works/nodetest
; HOME = /home/USER
; Run `npm config ls -l` to show all defaults
script
const https = require('https');
https.get('', (res) => {
console.log('statusCode:', res.statusCode);
console.log('headers:', res.headers);
const data = [];
res.on('data', (d) => {
data.push(d);
});
res.on('end', ()=>{
const result = data.join("")
console.log(result);
});
}).on('error', (e) => {
console.error(e);
});
HTTPS webpage Fetch Script error for
truncated but this repeats for multiple addresses
AggregateError [ETIMEDOUT]:
at internalConnectMultiple (node:net:1139:18)
at internalConnectMultiple (node:net:1215:5)
at Timeout.internalConnectMultipleTimeout (node:net:1739:5)
at listOnTimeout (node:internal/timers:596:11)
at process.processTimers (node:internal/timers:529:7) {
code: 'ETIMEDOUT',
[errors]: [
Error: connect ETIMEDOUT 104.16.3.35:443
at createConnectionError (node:net:1675:14)
at Timeout.internalConnectMultipleTimeout (node:net:1734:38)
at listOnTimeout (node:internal/timers:596:11)
at process.processTimers (node:internal/timers:529:7) {
errno: -110,
code: 'ETIMEDOUT',
syscall: 'connect',
address: '104.16.3.35',
port: 443
},
Error: connect ENETUNREACH 2606:4700::6810:1f22:443 - Local (:::0)
at internalConnectMultiple (node:net:1211:16)
at Timeout.internalConnectMultipleTimeout (node:net:1739:5)
at listOnTimeout (node:internal/timers:596:11)
at process.processTimers (node:internal/timers:529:7) {
errno: -101,
code: 'ENETUNREACH',
syscall: 'connect',
address: '2606:4700::6810:1f22',
port: 443
},
...
Full Error Log for the script
I hope someone can help me troubleshoot this.
I was getting ETIMEDOUT
when installing packages with nvm 0.40.1
, node 22.14.0
& npm v10.9.2
. Tried multiple fixes that's across the internet and nothing worked! (downgrade, upgrade, cleanup, switching dns, installing pihole on a machine & using that for dns!)
I wrote a simple script with require('https')
to read https://registry.npmjs.
and got a boatload of Aggregate Error
with ETIMEDOUT
for IP4
& ENETUNREACH
for IP6
when trying to get any package page eg: https://registry.npmjs./data-fns
At same time, fetching google, microsoft, docker & many more works!
So I decided to try these
- VirtualBox 7 + Debian 12 + NAT networking = Not Working, same errors for npm & script
- VirtualBox 7 + Debian 12 + BRIDGE networking = WORKING both script & npm install
- Docker - tried multiple LTS v18/20/22 = All WORKING both script & npm install
NPM Config for Kubuntu & Debian VM (on docker is default ie similar with different path)
$ npm config ls
; node bin location = /home/USER/.nvm/versions/node/v22.14.0/bin/node
; node version = v22.14.0
; npm local prefix = /home/USER/works/nodetest
; npm version = 10.9.2
; cwd = /home/USER/works/nodetest
; HOME = /home/USER
; Run `npm config ls -l` to show all defaults
script
const https = require('https');
https.get('https://registry.npmjs./data-fns', (res) => {
console.log('statusCode:', res.statusCode);
console.log('headers:', res.headers);
const data = [];
res.on('data', (d) => {
data.push(d);
});
res.on('end', ()=>{
const result = data.join("")
console.log(result);
});
}).on('error', (e) => {
console.error(e);
});
HTTPS webpage Fetch Script error for https://registry.npmjs.
truncated but this repeats for multiple addresses
AggregateError [ETIMEDOUT]:
at internalConnectMultiple (node:net:1139:18)
at internalConnectMultiple (node:net:1215:5)
at Timeout.internalConnectMultipleTimeout (node:net:1739:5)
at listOnTimeout (node:internal/timers:596:11)
at process.processTimers (node:internal/timers:529:7) {
code: 'ETIMEDOUT',
[errors]: [
Error: connect ETIMEDOUT 104.16.3.35:443
at createConnectionError (node:net:1675:14)
at Timeout.internalConnectMultipleTimeout (node:net:1734:38)
at listOnTimeout (node:internal/timers:596:11)
at process.processTimers (node:internal/timers:529:7) {
errno: -110,
code: 'ETIMEDOUT',
syscall: 'connect',
address: '104.16.3.35',
port: 443
},
Error: connect ENETUNREACH 2606:4700::6810:1f22:443 - Local (:::0)
at internalConnectMultiple (node:net:1211:16)
at Timeout.internalConnectMultipleTimeout (node:net:1739:5)
at listOnTimeout (node:internal/timers:596:11)
at process.processTimers (node:internal/timers:529:7) {
errno: -101,
code: 'ENETUNREACH',
syscall: 'connect',
address: '2606:4700::6810:1f22',
port: 443
},
...
Full Error Log for the script
Share Improve this question asked Mar 30 at 17:44 VemmanVemman 14 bronze badges 1- Why the downvotes did anyone read the question? – Vemman Commented Mar 30 at 21:25
1 Answer
Reset to default 0I think I found a solution. This discussion comment on next.js on github has a similar setup like me - behind a 5G router instead of wired connection to ISP.
Adding the option --network-family-autoselection-attempt-timeout=500
and setting it on NODE_OPTIONS
environment variable has solved issue for me as well. As said in the github comment the default --network-family-autoselection-attempt-timeout
is 250ms, increasing this seems to be the solution.
export NODE_OPTIONS="--network-family-autoselection-attempt-timeout=500"
The issue is probably related to TypeError: fetch failed - on Node v20.11.1 and v21.7.1, but works on v18.19.1 -
PS: Baffling thing is Debian 12+NAT on VirtualBox also started working!