R
Railway16mo ago
xed20

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
Percy
Percy16mo ago
Project ID: N/A
xed20
xed2016mo ago
Brody
Brody16mo ago
can you connect to postgres locally with something like pgadmin?
xed20
xed2016mo ago
ye when I connect locally it's work fine
Brody
Brody16mo ago
are you using a dockerfile?
xed20
xed2016mo ago
nope
xed20
xed2016mo ago
Brody
Brody16mo ago
try restarting the database plugin settings
xed20
xed2016mo ago
I just restarted now, still show the same error
Brody
Brody16mo ago
sounds like a box networking issue i will flag the team for you
xed20
xed2016mo ago
Ok thanks
Percy
Percy16mo ago
Flagging this thread. A team member will be with you shortly.
xed20
xed2016mo ago
I tried to put pgadmin URL and I got the same error
Error connecting to PostgreSQL PrismaClientInitializationError: Can't reach database server at `localhost`:`5432`
Please make sure your database server is running at `localhost`:`5432`.
at r (/app/node_modules/@prisma/client/runtime/library.js:103:2766)
at async Object.connect (/app/db/pgsql.js:7:5)
at async startServer (/app/app.js:71:5) {
clientVersion: '5.0.0',
errorCode: 'P1001'
}
Error connecting to PostgreSQL PrismaClientInitializationError: Can't reach database server at `localhost`:`5432`
Please make sure your database server is running at `localhost`:`5432`.
at r (/app/node_modules/@prisma/client/runtime/library.js:103:2766)
at async Object.connect (/app/db/pgsql.js:7:5)
at async startServer (/app/app.js:71:5) {
clientVersion: '5.0.0',
errorCode: 'P1001'
}
Brody
Brody16mo ago
that says localhost so you're definitely doing something wrong there
xed20
xed2016mo ago
yep I know it's localhost I meant either the url from Railway or my localhost url i get the same error message
Brody
Brody16mo ago
then this isn't a railway issue? and I flagged the team for nothing 😭
xed20
xed2016mo ago
Oops! sorry
Brody
Brody16mo ago
do you have a database running locally on port 5432
xed20
xed2016mo ago
wait a minute hmm, when i put Railway URL locally its works
char8
char816mo ago
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.
xed20
xed2016mo ago
I got this error when you Railway DB URL
Error connecting to PostgreSQL PrismaClientInitializationError: Can't reach database server at `containers-us-west-207.railway.app`:`6149`
Please make sure your database server is running at `containers-us-west-207.railway.app`:`6149`.
at r (/app/node_modules/@prisma/client/runtime/library.js:103:2766)
at async Object.connect (/app/db/pgsql.js:7:5)
at async startServer (/app/app.js:71:5) {
clientVersion: '5.0.0',
errorCode: 'P1001'
}
Error connecting to PostgreSQL PrismaClientInitializationError: Can't reach database server at `containers-us-west-207.railway.app`:`6149`
Please make sure your database server is running at `containers-us-west-207.railway.app`:`6149`.
at r (/app/node_modules/@prisma/client/runtime/library.js:103:2766)
at async Object.connect (/app/db/pgsql.js:7:5)
at async startServer (/app/app.js:71:5) {
clientVersion: '5.0.0',
errorCode: 'P1001'
}
Do i need to add some code to my repo? or just adjust the time out on the Railway
char8
char816mo ago
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 so
xed20
xed2016mo ago
It's work now i added connect_timeout=30 as you mentioned above 👍🏻
Brody
Brody16mo ago
sorry for the flag char, i will keep this in mind for any similar issues in the future
xed20
xed2016mo ago
So i have two choices make the repo public or add connect_timeout=30 it's that correct?
Brody
Brody16mo ago
where did anyone say about making the repo public?
char8
char816mo ago
not making the repo public, disable private networking by using this button in project settings
xed20
xed2016mo ago
I see
char8
char816mo ago
thanks and no worries!
xed20
xed2016mo ago
Thanks for helping , I learned new lesson today i guess and sorry for the disturb ❤️
Want results from more Discord servers?
Add your server