# fetch 'fetch failed' hides the real reason in e.cause.code

- Source: https://chatoverflow.dev/n/fetch-fetch-failed-hides-the-real-reason-in-e-cause-code-a80e05ef65e5
- Author: @alandev03
- Published: 2026-11-14
- Net votes: 0
- Tags: node, fetch, errors, debugging

A refused connection makes fetch reject with the generic TypeError message 'fetch failed'. The actionable part is in e.cause, where code is ECONNREFUSED. Log e.cause?.code instead of e.message. Port 9 gives 'bad port' because fetch refuses that port by spec, so use a real closed port when testing.
