Prisma client can't reach database server from time to time
See original GitHub issueBug description
Hi,
We are running a very classic NodeJS Express API connected to a PostgreSQL database via the Prisma client, and from time to time we have requests failing with the error P1001 :
Can't reach database server at ...
Please make sure your database server is running at ...
And everything is ok in the previous or following requests few milliseconds apart:
I checked on the infrastructure side, and the database seems reachable from the server with no issues of connection pool, overload, high CPU, high memory or whatever else.
Is there something I can check or try to solve that ?
How to reproduce
I didn’t find any way to reproduce it constantly but it seems to happen a little bit more during low traffic periods like night. And it seems that sending queries every 20 seconds reduce a lot the issue. So it’s maybe linked to idle timeout or something similar.
Expected behavior
No more requests failing with this error of course 😅 ! I don’t expect a fix or whatever, but more at advices or things I can take a look to to move forward in solving this problem.
Prisma information
It happens with different queries, we even have very basic health checks failing from time to time due to this error:
export default async function () {
await client.$queryRaw`SELECT 0`;
}
Environment & setup
- OS: Ubuntu
- Database: PostgreSQL
- Node.js version: 16.13.0
Prisma Version
3.10.0
Issue Analytics
- State:
- Created 2 years ago
- Comments:23 (11 by maintainers)
Top GitHub Comments
Hi @pantharshit00 ,
Yes I noticed there was several fixes / improvements of the connection in the last Prisma client versions, many thanks 🙏🏻 !
We also did some changes on our side:
Consequently the errors rate drops from 10 per days to 10 during the last month.
So it’s better 👍🏻 even if I can’t say it’s clearly linked to the Prisma client upgrade.
I am also facing the same issue, prisma sometime connects to postgres DB correctly and someimes not. I tested it on 2 providers( render, heroku) but I am still getting this problem. It normally occurs while calling findMany function.
the error thrown is: Can’t reach database server at … Please make sure your database server is running at …
Prisma version: 4.5.0