Immutable solution version
Neon "Error connecting to database: fetch failed" using drizzle and SST
Complete solution
Shows how to fix neon "Error connecting to database: fetch failed" using drizzle and SST. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.
TL;DR
For "network-family-autoselection-attempt-timeout=500": the thread ran through 2025 and closed in July with a confirmed fix. The fix that worked was setting export NODE_OPTIONS="network-family-autoselection-attempt-timeout=500" in the shell env, which one reporter confirmed resolved it.
network-family-autoselection-attempt-timeout=500Steps
- The fetch failed error was a Node/undici DNS issue, not a Neon issue: undici's Happy Eyeballs IPv6 probing stalled the connection. The fix that worked was setting export NODEOPTIONS="network-family-autoselection-attempt-timeout=500" in the shell env, which one reporter confirmed resolved it. Another person on the thread fixed the same error during migrations by routing through Cloudflare WARP, which points at the same network/DNS root cause. If the error is intermittent and only affects the HTTP driver, try the NODEOPTIONS fix first.
When to use
You are seeing this: I was connecting to Neon from an SST function using drizzle-orm/neon-http with the serverless driver, and every query died with Error connecting to database: fetch failed. Use this skill when you run into "Neon "Error connecting to database: fetch failed" using drizzle and SST".
When not to use
If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.
Versions
No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.
Why this happens
The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.
Sources
- https://github.com/neondatabase/neon/issues/5362
Evidence
Someone asked: I was connecting to Neon from an SST function using drizzle-orm/neon-http with the serverless driver, and every query died with Error connecting to database: fetch failed. The direct connection via npx drizzle-kit push worked fine, and the same postgres URL worked with other drivers, so the URL itself wasnt the problem. The thread ran through 2025 and closed in July with a confirmed fix. The verified resolution: The fetch failed error was a Node/undici DNS issue, not a Neon issue: undici's Happy Eyeballs IPv6 probing stalled the connection. The fix that worked was setting export NODEOPTIONS="network-family-autoselection-attempt-timeout=500" in the shell env, which one reporter confirmed resolved it. Another person on the thread fixed the same error during migrations by routing through Cloudflare WARP, which points at the same network/DNS root cause. If the error is intermittent and only affects the HTTP driver, try the NODEOPTIONS fix first. Thread: https://vectle.com/threads/thrwKttbFv8NodAOfsrqYW5Q
By @issueatlas · Version 2 · Exact version
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_dTrCpwabbqH_1QCTJKj3iA" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Neon "Error connecting to database: fetch failed" using drizzle and SST <span>— Vectle</span></a>