P
Prisma3w ago
toasty

P1001: Can't reach database server at api.mydomain.com:5432

Been debugging this for hours, nothing works - I'm using the exact same connection string via Psql and it works, I've double check encoding, open port, password, dns resolution, everything
6 Replies
Prisma AI Help
You chose to debug with a human. They'll tinker with your query soon. If you get curious meanwhile, hop into #ask-ai for a quick spin!
toasty
toastyOP3w ago
WOW, prisma is ridiculous, the ONLY way i could get it to work was to socat TCP4-LISTEN:5432,reuseaddr,fork TCP4:api.domain.com:5432 Prisma team please fix this asap, cant even connect to the db using your orm, might as well drop it
Nurul
Nurul3w ago
Hey! Did this happen on latest prisma version 6.6.0? Which database are you using?
toasty
toastyOP2w ago
im on 6.6.0 @Nurul postgres this is still happening, its very dissapointing as ive migrated my old setup to prisma and now when i try to connect to my production instance i literally cannot do so trying via direct ip also does not work
Nurul
Nurul2w ago
This is very strange as I haven't seen other users run into it. I assume you have self hosted your database and aren't using Postgres on a Cloud provider like Neon, Supabase, AWS etc. Are you able to connect to this postgres instance via a database IDE like pgAdmin, Dbeaver etc?
toasty
toastyOP2w ago
yes its self hosted on a custom setup, even stranger is that connecting to it via typescript code works, but using the exact same string in the schema.prisma file does not work, so i cannot run migrations, db push, etc: this works:
const prisma = new PrismaClient({
datasources: {
db: {
url: Bun.env.DATABASE,
},
},
});
const prisma = new PrismaClient({
datasources: {
db: {
url: Bun.env.DATABASE,
},
},
});
this doesn't:
datasource db {
provider = "postgresql"
url = env("DATABASE")
}
datasource db {
provider = "postgresql"
url = env("DATABASE")
}
I've actually noticed this same issue when using postgres within orbstack, orb assigns domains within the local machine and prisma is unable to resolve them, eg a local postgres container is running on postgres.backend.orb.local:5432 but prisma cannot connect to it whereas psql, tableplus, beekeeper, etc can all connect to this. i think there is an issue with how prismas engine is resolving dns in general, the prisma js package does not seem to do this so you can reproduce this problem by running pg within a docker container via orbstack, and trying to connect to the .orb.local domain of the container in your schema.prisma file. @Nurul though seeing this issue on a common tld like .com or .net on the public internet is much more concerning compared to not being able to resolve .orb.local

Did you find this page helpful?