How to set up @vercel/postgres for locally installed database
Unanswered
Red-naped Sapsucker posted this in #help-forum
Red-naped SapsuckerOP
I'm running a PostgreSQL database on localhost. How do I have to set up my project using
@vercel/postgres, so I can connect to that local db?3 Replies
Red-naped SapsuckerOP
Is this package bugged or something? Using it is literally the only way I can not connect to my local db.
- works ✅ running this in command line
- works ✅ using
- fails ⌠using
having set
gives the following error:
- works ✅ running this in command line
psql postgres://postgres:password@localhost:5432/test- works ✅ using
pg package directly, which is used internally by @vercel/postgres:import { Client } from "pg";
const client = new Client( {
host: "localhost",
port: 5432,
user: "postgres",
password: "password",
database: "test",
} );
await client.connect();
await client.query( "SELECT NOW()" );- fails ⌠using
@vercel/postgres, trying to run "await sqlSELECT NOW()"having set
POSTGRES_URL=postgres://postgres:password@localhost:5432/testgives the following error:
NeonDbError: Error connecting to database: fetch failed
at eval (webpack-internal:///(sc_server)/./node_modules/@neondatabase/serverless/index.js:4684:21)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async GET (webpack-internal:///(sc_server)/./src/app/api/test/route.ts:23:21)
at async eval (webpack-internal:///(sc_server)/./node_modules/next/dist/server/future/route-modules/app-route/module.js:253:37) {
code: null,
sourceError: TypeError: fetch failed
at Object.fetch (node:internal/deps/undici/undici:11457:11)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
cause: Error: connect ECONNREFUSED ::1:443
at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1494:16)
at TCPConnectWrap.callbackTrampoline (node:internal/async_hooks:130:17) {
errno: -4078,
code: 'ECONNREFUSED',
syscall: 'connect',
address: '::1',
port: 443
}
}
}Araucanian herring
I'm seeing the same issue. did you figure out a solution?
Araucanian herring
Looks like this is an open issue - related to neon serverless and localhost. tracked here https://github.com/vercel/examples/issues/701