Error connecting to PostgreSQL PrismaClientInitializationError: Can't reach database server
I'm trying to connect to the DB,
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
30 Replies
Project ID:
N/A
can you connect to postgres locally with something like pgadmin?
ye when I connect locally it's work fine
are you using a dockerfile?
nope
try restarting the database
plugin settings
I just restarted now, still show the same error
sounds like a box networking issue
i will flag the team for you
Ok thanks
Flagging this thread. A team member will be with you shortly.
I tried to put pgadmin URL and I got the same error
that says localhost
so you're definitely doing something wrong there
yep I know it's localhost I meant either the url from Railway or my localhost url i get the same error message
then this isn't a railway issue?
and I flagged the team for nothing 😭
Oops! sorry
do you have a database running locally on port 5432
wait a minute hmm, when i put Railway URL locally its works
let us know if it's a railway issue - but just wanted to note that I've seen a few cases now with Prisma and private networking, where the default
connect_timeout
in the postgres connection string is too short. So either need to disable private networking in the service settings page or add connection_timeout=30
to the connection string given to Prisma.I got this error when you Railway DB URL
Do i need to add some code to my repo? or just adjust the time out on the Railway
It's a setting in prisma, so you'll need to set it in your code. See:
https://www.prisma.io/docs/concepts/database-connectors/postgresql
apologies, the setting is
connect_timeout
, and it should be set to 30 or soIt's work now i added connect_timeout=30 as you mentioned above 👍🏻
sorry for the flag char, i will keep this in mind for any similar issues in the future
So i have two choices make the repo public or add connect_timeout=30 it's that correct?
where did anyone say about making the repo public?
not making the repo public, disable private networking by using this button in project settings
I see
thanks and no worries!
Thanks for helping , I learned new lesson today i guess and sorry for the disturb ❤️