NeonDbError: Error connecting to database: fetch failed
Hi team,
I was using Drizzle to migrate the database from the preview branch that was integrated with Vercel, but I got that error.
Here are the code snippets:
migrate.ts
package.json
Any kind of help would be appreciated π26 Replies
stormy-goldβ’2y ago
Any additional error information? Can you share your DATABASE_URL value (remove the password before sending it)
ambitious-aquaOPβ’2y ago
Hey @Conrad Ludgate , there you go:
DATABASE_URL="postgres://feedbackpaw_owner:xxx@ep-long-paper-a5w2o9e3-pooler.us-east-2.aws.neon.tech/feedbackpaw?sslmode=require"
Some additional errors are attached.
stormy-goldβ’2y ago
ah, the illusive ETIMEDOUT error again. this one is very perculiar
Can you try https://discord.com/channels/1176467419317940276/1176467419938701375/1217607005661827293
ambitious-aquaOPβ’2y ago
Iβm away from the keyboard right now, but Iβll try it soon.
Coincidentally, Iβm using Node 20 here, which will be the main issue according to the chat that you referenced.
Letβs see thenβ¦
stormy-goldβ’2y ago
Also, are you located in the US or outside? I wonder if node's default TCP timeout is set quite low
ambitious-aquaOPβ’2y ago
Not in the US at the moment. Do you have any recommendations to adjust the timeout?
stormy-goldβ’2y ago
Some more answers from SO
https://stackoverflow.com/a/33351352
https://stackoverflow.com/a/76465378
https://stackoverflow.com/a/76344394
Stack Overflow
What could cause "connect ETIMEDOUT" error when the URL is working ...
I train myslef with NodeJS and tried a simple GET call.
Here is my code:
var http = require('http');
var options = {
host: 'www.boardgamegeek.com',
path: '/xmlapi/boardgame/1?stats=1',
Stack Overflow
Socket connection timout error in Node js
I've been having trouble uploading images to cloudinary in Node JS because when I try to I get this error
Error [ERR_SOCKET_CONNECTION_TIMEOUT]: Socket connection timeout
{
error: Error [
Stack Overflow
Socket connection timout error in Node js
I've been having trouble uploading images to cloudinary in Node JS because when I try to I get this error
Error [ERR_SOCKET_CONNECTION_TIMEOUT]: Socket connection timeout
{
error: Error [
stormy-goldβ’2y ago
I'm struggling to find the config to set the timeout :/
Node docs are not the greatest
helpful-purpleβ’2y ago
Interesting that Node.js 20 is correlated. Is that when they switched the fetch implementation to Undici?
ambitious-aquaOPβ’2y ago
So I downgraded the Node version to
18.20.2 and it works. Thanks, Conrad πstormy-goldβ’2y ago
I think we need to add node 20 to our internal test suite. It's rather unfortunate that this is happening
helpful-purpleβ’2y ago
Yeah, something funky is going on with DNS or fetch. IIRC I tested with another user via DM and timeouts were occurring before fetch was invoked, like the timeout was βrandomlyβ thrown between 700-1000ms of calling
neonother-emeraldβ’2y ago
I'm having trouble in connecting the db
Can anyone help me with that?
xenial-blackβ’2y ago
what is the issue?
other-emeraldβ’2y ago
This is my drizzle.config.ts file
import type { Config } from "drizzle-kit";
export default {
schema: "src/db/schema.ts",
out: "src/drizzle",
driver: "pg",
dbCredentials: {
connectionString: process.env.NEON_DB_URL! as string,
},
schemaFilter: ["public"],
} satisfies Config;
other-emeraldβ’2y ago

other-emeraldβ’2y ago
I'm making a todo app to get hands on with this tech, but found this error which is like bothering me so much.
xenial-blackβ’2y ago
which node version are you on 20?
other-emeraldβ’2y ago
18.20.2
helpful-purpleβ’2y ago
Can you post the full error text instead of a screenshot?
Also, are you using WSL? Seems WSL has networking limitations: https://discord.com/channels/1176467419317940276/1176467419938701375/1233168994584756296
other-emeraldβ’2y ago
this is the error:
other-emeraldβ’2y ago
This is the GET API
export const GET = async (req: NextRequest, res: NextResponse) => {
// try {
console.log("first call");
const dbData = await db.select().from(todo);
return NextResponse.json({ message: "Get Successfull req", data: dbData }); // } catch (error) { // return NextResponse.json({ message: "Error getting next request" }); // } };
return NextResponse.json({ message: "Get Successfull req", data: dbData }); // } catch (error) { // return NextResponse.json({ message: "Error getting next request" }); // } };
helpful-purpleβ’2y ago
Are you using WSL?
What is the output of
console.log(process.version). I think you might be using Node.js v20 since the error message mentioned Undici and some users have had issues with Node.js v20 that we have yet to explore: node:internal/deps/undici/undici:12442:11
Oh my mistake. It seems Undici is in Node.js v18 also.
Are you able to connect using psql from a terminal?
Another thing you can try (if psql works), start a Node.js process that uses the Neon driver with --no-experimental-fetch , e.g node neon-test.js --no-experimental-fetch and see if that worksfair-roseβ’2y ago
Is there a known issues page somewhere?
Relatedly, is the recommendation to stay on node 18? I'm in the process of updating to 20 but saw this thread.
helpful-purpleβ’2y ago
We have an issue tracker on GitHub @san4d https://github.com/neondatabase/serverless/issues/76
Are you seeing the same behaviour?
GitHub
Transactions not working in Node 20 Β· Issue #76 Β· neondatabase/serv...
I previously had no issues until I tried to upgrade from node 18.19.1 to 20.12.2. When making a parallel insert in a transaction, it seems to lose sight of the transaction scope when using neon ser...
fair-roseβ’2y ago
Not yet. I'll update that thread if there's an issue