Error: P1001: Can't reach database server (PlanetScale)
See original GitHub issueBug description
Hello, I’m trying out Prisma with PlanetScale and it’s not going so smooth because I’m getting the following error after typing npx prisma migrate dev
:
prisma:loadEnv project root found at /home/goodwin/flaut-nextjs/package.json +0ms
prisma:tryLoadEnv Environment variables loaded from /home/goodwin/flaut-nextjs/.env +0ms
[dotenv][DEBUG] did not match key and value when parsing line 1: # Created by Vercel CLI
[dotenv][DEBUG] did not match key and value when parsing line 19:
Environment variables loaded from .env
prisma:engines using Node API: false +0ms
prisma:engines binaries to download query-engine, migration-engine, introspection-engine, prisma-fmt +0ms
Prisma schema loaded from prisma/schema.prisma
prisma:getConfig Using Query Engine Binary at: /home/goodwin/flaut-nextjs/node_modules/@prisma/engines/query-engine-debian-openssl-1.1.x +0ms
Datasource "db": MySQL database "flautru" at "g8oms8wlmppb.eu-west-2.psdb.cloud:3306"
prisma:getDMMF Using Query Engine Binary at: /home/goodwin/flaut-nextjs/node_modules/@prisma/engines/query-engine-debian-openssl-1.1.x +0ms
prisma:getConfig Using Query Engine Binary at: /home/goodwin/flaut-nextjs/node_modules/@prisma/engines/query-engine-debian-openssl-1.1.x +34ms
prisma:getConfig Using Query Engine Binary at: /home/goodwin/flaut-nextjs/node_modules/@prisma/engines/query-engine-debian-openssl-1.1.x +11ms
Error: Error: P1001: Can't reach database server at `g8oms8wlmppb.eu-west-2.psdb.cloud`:`3306`
Please make sure your database server is running at `g8oms8wlmppb.eu-west-2.psdb.cloud`:`3306`.
at ensureDatabaseExists (/home/goodwin/flaut-nextjs/node_modules/prisma/build/index.js:63712:13)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async _MigrateDev.parse (/home/goodwin/flaut-nextjs/node_modules/prisma/build/index.js:65680:28)
at async main (/home/goodwin/flaut-nextjs/node_modules/prisma/build/index.js:105366:18)
I’ve been able to establish successfull connection with both MySQL Workbench GUI for Windows and mysql-client
for Linux (WSL2). The only thing that is failing is Prisma.
How to reproduce
- Create database via app.planetscale.com
- Create new branch out of
main
- Copy both
main
anddev
branch URLs to Vercel - Execute
vercel pull
to get env variables (so now prod URL points tomain
and shadow database URL points todev
branch) - Make schema changes to
schema.prisma
- Execute
npm prisma migrate dev
Expected behavior
No response
Prisma information
Environment & setup
- OS: Windows 10, WSL2
- Database: PlanetScale MySQL
- Node.js version: v12.22.1
Prisma Version
prisma : 2.29.1
@prisma/client : 2.29.1
Current platform : debian-openssl-1.1.x
Query Engine : query-engine 1be4cd60b89afa04b192acb1ef47758a39810f3a (at node_modules/@prisma/engines/query-engine-debian-openssl-1.1.x)
Migration Engine : migration-engine-cli 1be4cd60b89afa04b192acb1ef47758a39810f3a (at node_modules/@prisma/engines/migration-engine-debian-openssl-1.1.x)
Introspection Engine : introspection-core 1be4cd60b89afa04b192acb1ef47758a39810f3a (at node_modules/@prisma/engines/introspection-engine-debian-openssl-1.1.x)
Format Binary : prisma-fmt 1be4cd60b89afa04b192acb1ef47758a39810f3a (at node_modules/@prisma/engines/prisma-fmt-debian-openssl-1.1.x)
Default Engines Hash : 1be4cd60b89afa04b192acb1ef47758a39810f3a
Studio : 0.419.0
Preview Features : planetScaleMode, nApi
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:9 (4 by maintainers)
Top Results From Across the Web
prisma Error: p1001: Can't reach database server at `db ...
I had a similar issue with a Sveltekit application using Prisma and PlanetScale (MySQL) and Docker on Windows (WSL).
Read more >Error message reference - Prisma
P1001. "Can't reach database server at {database_host} : {database_port} Please make sure your database server is running at {database_host} ...
Read more >Error: P1001: Can't reach database server at `localhost`:`5200`
Coding example for the question Error: P1001: Can't reach database server at `localhost`:`5200`-docker.
Read more >How to set up Next.js with Prisma and PlanetScale
We'll walk through setting up a new database, installing Prisma, defining your ... we log the error and respond with a server code...
Read more >connecting to planetscale database from a docker ... - Fly.io
2022-06-10T12:46:22.144 app[8942000f] lhr [info] Error: P1001: Can't reach database server at qd6hc1lvteex.eu-west-3.psdb.cloud : 3306.
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
Yep, replacing
/etc/pki/tls/certs/ca-bundle.crt
with/etc/ssl/certs/ca-certificates.crt
for local environment solved the issue. The solution for me at this point would be having four different URLs at Vercel environment variables list (two with/etc/ssl/certs/ca-certificates.crt
for local and two with/etc/pki/tls/certs/ca-bundle.crt
for preview and prod). Thank you for your help.Thanks for the feedback, and sorry this was so confusing and required you to actually create an issue here. I opened https://github.com/prisma/prisma/issues/8890 to hopefully make the error message a bit more insightful.