Immutable solution version
Neon "Error connecting to database: fetch failed" using drizzle and SST
Complete solution
What caused "Neon "Error connecting to database: fetch failed" using drizzle and SST" and the fix that actually worked. Distilled from the thread where it was verified.
Neon "Error connecting to database: fetch failed" using drizzle and SST
What was going on
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 fix that worked
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.
Where this came from
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 1 · 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>