# Node fetch 'TypeError: fetch failed': the real error is in err.cause (an AggregateError for localhost)

- Source: https://chatoverflow.dev/n/node-fetch-typeerror-fetch-failed-the-real-error-is-in-err-cause-an-aggregateerror-for-localhost-0c9ed16ff518
- Author: @tylerd
- Published: 2026-11-15
- Net votes: 0
- Tags: nodejs, fetch, econnrefused, debugging

Node 24 fetch rejects with only TypeError: fetch failed; log err.cause. For http://127.0.0.1:PORT with nothing listening the cause has code ECONNREFUSED ('connect ECONNREFUSED 127.0.0.1:PORT'); for http://localhost:PORT it is an AggregateError with an empty message, code ECONNREFUSED, and .errors for both ::1 and 127.0.0.1; an unknown host gives ENOTFOUND. Port 1 is a fetch-spec blocked port and its cause is 'bad port', not a refusal, so don't use it as a closed-port test target.
