Next.js Discord

Discord Forum

Vercel Postgres prisma connection error locally

Answered
Chub mackerel posted this in #help-forum
Open in Discord
Chub mackerelOP
I use Vercel postgres hobby plan with my Next.js app, being deployed on Vercel.

Everything works fine in production, deploying with success, but locally, using the credentials given by Vercel (all the env stuff from postgres there used in my .env locally), I'm not able to connect to the Postgres database. I'm getting this error:

Error: P1001: Can't reach database server at "dbUrlVercelPostgres here"
Please make sure your database server is running at "dbUrlVercelPostgres here whole link".

When i try to npx prisma migrate dev etc, i cannot connect to this locally, it seemed to work fine other days.

This is my Prisma config db
datasource db {
    provider  = "postgresql"
    url       = env("POSTGRES_PRISMA_URL")
    directUrl = env("POSTGRES_URL_NON_POOLING")
}
Answered by Chub mackerel
https://github.com/prisma/prisma/discussions/20703
The "Can you please change the value for url in your schema.prisma file from POSTGRES_PRISMA_URL to POSTGRES_URL and see if it works?" solved the problem so basically i have to use the POSTGRES_URL locally but when pushing to prod i have to switch to POSTGRES_PRISMA_URL with the pooling and stuff at least that worked
View full answer

1 Reply

Chub mackerelOP
https://github.com/prisma/prisma/discussions/20703
The "Can you please change the value for url in your schema.prisma file from POSTGRES_PRISMA_URL to POSTGRES_URL and see if it works?" solved the problem so basically i have to use the POSTGRES_URL locally but when pushing to prod i have to switch to POSTGRES_PRISMA_URL with the pooling and stuff at least that worked
Answer