Fixing Neon connection timeouts in local Astro development
After installing Neon and testing it locally, the database query failed with:
NeonDbError: Error connecting to database: TypeError: fetch failed
The setup itself was correct: the Neon connection string was loaded, the Netlify adapter was installed, and Astro was using output: 'server'.
Testing both the pooled and non-pooled Neon URLs produced the same error. A plain Node fetch() request to the Neon endpoint failed with ETIMEDOUT, even though curl could reach the same endpoint.
That confirmed the issue was local Node networking, not Astro, Netlify, Neon, or the database code.
The fix was to increase Node’s network-family autoselection timeout in the local dev script:
{
"scripts": {
"dev": "NODE_OPTIONS='--network-family-autoselection-attempt-timeout=5000' astro dev"
}
}
This gives Node more time when trying IPv4/IPv6 connection attempts locally.
This is only a local development workaround. Production on Netlify should not need it unless the same ETIMEDOUT error appears there.