N
Neonβ€’2y ago
passive-yellow

`@neondatabase/serverless` connection string doesn't accept strings without passwords?

Couldn't find much info on this online, but I'm runnign into an odd error with @neondatabase/serverless and trying to initiate a neon instance. Using the snippet from the drizzle docs:
import { drizzle } from "drizzle-orm/neon-http";
import { neon } from "@neondatabase/serverless";

const sql = neon("postgres://postgres@10.0.0.25/drizzletest");

export const db = drizzle(sql);
import { drizzle } from "drizzle-orm/neon-http";
import { neon } from "@neondatabase/serverless";

const sql = neon("postgres://postgres@10.0.0.25/drizzletest");

export const db = drizzle(sql);
It's error out saying:
Error: Database connection string format for `neon()` should be: postgresql://user:password@host.tld/dbname?option=value
Error: Database connection string format for `neon()` should be: postgresql://user:password@host.tld/dbname?option=value
Now I know that the protocol prefix postgres:// (as opposed to postgresql:// as shown in the error example) should work, its shown that way elsewhere in the docs / the postgres ecosystem. I've tried both and it still errors. So I can only imagine that it doesnt like the fact that my user postgres doesn't have a password. Removing the user part entirely (so its just postgres://10.0.0.25:5432/drizzletest also throws the same error, not an auth error as might be expected) Is this not a supported syntax? I'm assuming neondatabase/serverless uses some preexisting postgres conneciton string parsing and/or this is a common enough use-case so this should work πŸ€” Or am I missing something simple maybe? πŸ€·β€β™‚οΈ
3 Replies
passive-yellow
passive-yellowOPβ€’2y ago
I'm using: - "@neondatabase/serverless": "^0.9.1" - "drizzle-orm": "^0.30.9" Yeah so adding a fake password does make that initial error disappear, ofc now the credentials are incorrect, but I can create another dummy psql user for this. This gets rid of that error for now:
postgresql://postgres:abc@10.0.0.25/drizzletest
postgresql://postgres:abc@10.0.0.25/drizzletest
I think parsing without a password should be supported, mostly for simplicity in dev envs Also somehow this connectionString
postgres://drizzle:drizzle@10.0.0.25:5432/drizzletest
postgres://drizzle:drizzle@10.0.0.25:5432/drizzletest
Gets parsed incorrectly too and throws the following error πŸ€”
NeonDbError: Error connecting to database: Failed to parse URL from https://api.0.0.25/sql
NeonDbError: Error connecting to database: Failed to parse URL from https://api.0.0.25/sql
I gave the host an entry in my /etc/hosts to get around this, but also maybe soemthign to look into πŸ€”
fascinating-indigo
fascinating-indigoβ€’2y ago
What host are you connecting to?
passive-yellow
passive-yellowOPβ€’2y ago
Local dev PG container Is that not supported? I read its a dropin replacement for the pg driver so I assumed it was. Oh you knwo what, that seems to be the websocket / @neondatabase/serverless package specifically, not the -http variant. Is that right?

Did you find this page helpful?