Intermittent P1001 - "Can't reach database server..."
See original GitHub issueBug description
While my app is running, I occasionally see logs for error P1001. The app continues to function and has access to the database for subsequent requests.
How to reproduce
This seems to be random, but seems to occur most often when the app is under load and has multiple connections to the database. The problem occurs on localhost DB and remote
Expected behavior
I’d like this error to provide more information. It is a strange error to receive while your app is actively connected to the database.
Prisma information
Environment & setup
- OS: Windows/Linux
- Database: 10.6.7-MariaDB
- Node.js version: 16
Prisma Version
Connector: MySQL/MariaDB
Prisma 3.15.1
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:14 (3 by maintainers)
Top Results From Across the Web
Error: P1001: Can't reach database server at `localhost`:`5432`
Looks like the application and the database are running on two separate containers. So, in this case, connecting to localhost:5432 from the ...
Read more >Help wanted: Error: P1001: Can't reach database server at "db ...
Hi all, Not sure I'm in the right place but I'm starting a new project and going through the docs to use supabase...
Read more >Troubleshooting for Amazon RDS - AWS Documentation
Can't connect to Amazon RDS DB instance. When you can't connect to a DB instance, the following are common causes: Inbound rules –...
Read more >Error: P1001: Can't reach database server at `dpg ...
Hey,. Without more context on how you're calling the Render db from your code, it's tough to help. I was able to access...
Read more >please make sure your database server is running at ...
Dailydevsblog.com > troubleshoot > resolved-error-p1001-cant-reach-database-server... Answer: Instead of using localhost:5200 as the address of the database, ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I work with @rflorence who commented a while back saying we were running into this error.
We solved this by upgrading our database to a bigger instance. The free memory it had was very low because we were running on a
t3.micro
RDS instance in AWS. Upgrading tot3.large
has solved this issue. The specific metric is “freeable memory” which was very low and it led to random db disconnections in our app. We missed this metric at first because it was consistently low on memory so there was no odd looking spike or dip whenever the errors occurred.tldr: make sure your db node has a lot of free memory. Hope that might help anyone else who has run into this issue.
Happens constantly on the first request for any Node service. The first request fails every time. Running the same code a second time, without restarting, it works perfectly. This is on a 32GB MacBook Pro M1 running the following:
@prisma/client : 4.4.0 prisma 4.4.0 node 16.17.0 macos 12.6 docker 20.10.17, build 100c701 docker compose 2.10.2
Have not looked into it, but it almost feels like the PrismaClient is using some type of singleton pattern and throwing the error prior to some underlying piece initializing. That could explain why subsequent calls succeed.