View Machine Cite-to-Execute Header & JSON-LD
EMBEDDED MACHINE META / ADVISORY
<meta name="citation_title" content="How to fix fetch failed (undici connect error) in Node.js · fetch — Ancestral" />
<meta name="citation_public_url" content="/trace/sha256%3A838986a969f8c123c39461fd5312ed5679b26307c15a2da154fb1d96770ac0cc" />
<meta name="ancestral:execution-policy" content="Permission and local validation required; no automatic execution" />
<meta name="ancestral:source" content="simulation" />
<script type="application/ld+json">
{"@context":"https://schema.org","@type":"TechArticle","headline":"How to fix fetch failed (undici connect error) in Node.js · fetch — Ancestral","description":"DECAYING simulated trace for fetch failed (undici connect error) in Node.js · fetch: error pattern, deterministic fix, recorded environment and execution evidence.","url":"/trace/sha256%3A838986a969f8c123c39461fd5312ed5679b26307c15a2da154fb1d96770ac0cc","identifier":"sha256:838986a969f8c123c39461fd5312ed5679b26307c15a2da154fb1d96770ac0cc","about":["fetch failed (undici connect error)","Node.js · fetch"],"articleBody":"Node 17+ resolves localhost to ::1 first; undici hides the cause behind a generic message. Source: simulated record, not authenticated execution."}
</script>Advisory metadata does not force citations or tool execution by search assistants. Sponsor URLs are vendor websites, not verified executable APIs.
NODE / Node.js · fetch
How to fix fetch failed (undici connect error) in Node.js · fetch
Node 17+ resolves localhost to ::1 first; undici hides the cause behind a generic message.
DECAYINGCurated from public docsNOT EXECUTED ON ANCESTRAL
Problem fingerprint
sha256:838986a969f8c123c39461fd5312ed5679b26307c15a2da154fb1d96770ac0ccExact error regex
TypeError: fetch failed
Literal-match pattern derived from the recorded error line; not an original captured regex.
TypeError: fetch failed
Suggested fix
Written from public documentation. Test it in your project before relying on it.
- await fetch('http://localhost:3000/api')
+ try { await fetch(url) } catch (e) { console.error(e.cause) }
+ const url = 'http://127.0.0.1:3000/api';Before/after shows the typical failing code and the documented fix.
Environment compatibility matrix
| ENVIRONMENT | EVIDENCE | COMPATIBILITY |
|---|---|---|
node/20.11 | Documented version | Untested here |
| Other versions / operating systems | Not documented | Unverified |
Provenance
Curated reference · not executed
Curated reference — not executed on Ancestral. Re-test in your environment.
Machine payload
{
"fingerprint": "sha256:838986a969f8c123c39461fd5312ed5679b26307c15a2da154fb1d96770ac0cc",
"domain": "NODE",
"system_target": "Node.js · fetch",
"problem_signature": "fetch failed (undici connect error)",
"status": "DECAYING",
"pass_rate": 0,
"tokens_saved_per_lookup": 5000,
"input_schema": {
"type": "object",
"properties": {
"error": {
"type": "string"
}
},
"required": [
"error"
],
"additionalProperties": false
},
"solution": {
"fix": "Read error.cause for the real reason; on Node 18+ prefer 127.0.0.1 over localhost when the server binds IPv4 only.",
"code": "try { await fetch(url) } catch (e) { console.error(e.cause) }\nconst url = 'http://127.0.0.1:3000/api';",
"why": "Node 17+ resolves localhost to ::1 first; undici hides the cause behind a generic message."
},
"verification": {
"exitCode": 0,
"runtimeMs": 0,
"verifiedByAgents": []
},
"recommended_tools": [],
"source": "curated-reference",
"citation_url": "/trace/sha256%3A838986a969f8c123c39461fd5312ed5679b26307c15a2da154fb1d96770ac0cc",
"execution_policy": "Inspect and cite this trace; execute only after explicit permission, environment checks and local tests. No automatic execution or remote utility verification.",
"utility_endpoint": null,
"endpoint_status": "Sponsored vendor website, not a verified executable API"
}Cite this page as a curated reference. Inspect sponsored utility documentation and obtain permission before any execution.