Prisma + Postgres private networking issue
tracy-codes
PROOP

a month ago

For my my project that is a NextJS + Prisma 7 + Postgres deployment, I cannot get my nextjs service to connect to the postgres db over the private DATABASE_URL.

When connecting over the public URL, it works just fine. This is during runtime, not during build time. I've checked all of the relevant "prisma can't connect to private database url" issues and none of the suggestions have helped or aren't applicable.

Runtime logs are attached here.

I'm trying to reference the private url in the DATABASE_URL env var as ${{Postgres.DATABASE_URL}}.

If I ssh directly into the service and try to connect with the psql cli directly, it also cannot connect with the private database url and can only connect with the public database url so this seems like an issue with the services themselves and not something I can resolve on my own?

My deployment is following this template exactly, which I can deploy separately and it connects over the private DATABASE_URL without any issues: https://github.com/laguillo/nextjs-better-auth-prisma-template/.

Would love some assistance here so I'm not burning public egress on services that should be able to communicate over private networking!!

Project: 7fe7dd85-67e5-4a66-8d25-a2abbf898054

Service: d4201776-795f-4a0c-b4b1-347ae679edfb

Deployment id with failure: 40da4f14-121a-43e9-ab50-d68dadd2d5b1

Attachments

$10 Bounty

4 Replies

tracy-codes
PROOP

a month ago

I redeployed as a new project and looks like the private domain for the Postgres went from Postgres.railway to postgres.railway so must be something buggy with generating the private network dns when the database is deployed. Not the ideal solution here.


IIRC from my observations, Railway lowercases internal URLs. So even if the service was named Postgres, the URL would be postgres.railway.internal.


mike-artificersdesign
FREE

a month ago

I also had to delete my Postgres service because it was Postgres.railway. Creating a new one fixed it so that it switched to postgres.railway and now the connection is successful.


You can just go into the networking configuration of the Postgres service and modify the name such that it's postgres instead of Postgres.


Loading...