N
Neon16mo ago
robust-apricot

Not able to connect from Next.js Vercel appp

HI Everyone we are facing a strange issue with our Next.js app where we when try to connect to NEON from our deployment or do a insert operation it fails with with SS attached Message whereas on local everything works perfectly fine honestly after being baffled for good 6 hours we have lost it any idea how to navigate the same our connection .ts
import { drizzle } from "drizzle-orm/neon-http";
import { NeonQueryFunction, neon} from "@neondatabase/serverless";
import * as schema from "./schema";
const connection = neon(process.env.POSTGRES_URL as string);
export const db = drizzle(connection as NeonQueryFunction<boolean, boolean>, {
schema,
});
import { drizzle } from "drizzle-orm/neon-http";
import { NeonQueryFunction, neon} from "@neondatabase/serverless";
import * as schema from "./schema";
const connection = neon(process.env.POSTGRES_URL as string);
export const db = drizzle(connection as NeonQueryFunction<boolean, boolean>, {
schema,
});
any help would be appreciated thank you
No description
9 Replies
generous-apricot
generous-apricot16mo ago
neondb seems to not be the name of your database perhaps you set it to something else
robust-apricot
robust-apricotOP16mo ago
Yes the db name is set to something else and the url contains the same But I don't know where this is picking neon_db
generous-apricot
generous-apricot16mo ago
can you paste your POSTGRES_URL without the password
dependent-tan
dependent-tan16mo ago
and the last part in your connection string would be /neondb which needs to be changed to your db name
dependent-tan
dependent-tan16mo ago
you can pick the relevant string by selecting db in neon's console
No description
robust-apricot
robust-apricotOP16mo ago
sure here is the dev and qa url Please note we are getting this issue in both dev and qa
#development
# POSTGRES_URL="postgresql://cred_dev_user:[password]@ep-solitary-base-a2g0farq.eu-central-1.aws.neon.tech/cred_dev_db?sslmode=require"
# QA
POSTGRES_URL=postgresql://cred_qa_user:[password]@ep-falling-waterfall-a21bwjkd.eu-central-1.aws.neon.tech/cred_qa_db?sslmode=require
#development
# POSTGRES_URL="postgresql://cred_dev_user:[password]@ep-solitary-base-a2g0farq.eu-central-1.aws.neon.tech/cred_dev_db?sslmode=require"
# QA
POSTGRES_URL=postgresql://cred_qa_user:[password]@ep-falling-waterfall-a21bwjkd.eu-central-1.aws.neon.tech/cred_qa_db?sslmode=require
dependent-tan
dependent-tan16mo ago
And does the role cred_dev_user and cred_qa_user roles have priviledges to insert data?
robust-apricot
robust-apricotOP16mo ago
Hi everyone, Thank you all for your suggestions and support. It turns out that the issue was due to an environment variable mismatch on Vercel. Our local .env files had the correct POSTGRES_URL, but the environment variables on Vercel were not properly set, leading to the database connection errors. We have updated the environment variables in Vercel with the correct database URLs, and everything is now working as expected. Thank you for pointing us in the right direction and helping us resolve this issue! Best regards, NInjajinja
dependent-tan
dependent-tan16mo ago
Glad it's resolved!

Did you find this page helpful?