Error P1001 Can't reach database server at AWS RDS (MySQL)
See original GitHub issueBug description
I am trying to migrate my models to an AWS RDS (MySQL) database, but I am encountering this error:
Environment variables loaded from .env
Prisma schema loaded from prisma/schema.prisma
Datasource "db": MySQL database "dbname" at "hostname.rds.amazonaws.com:3306"
MySQL database dbname created at hostname.rds.amazonaws.com:3306
Error: P1001
Can't reach database server at `hostname.rds.amazonaws.com`:`3306`
How to reproduce
Steps to reproduce the behavior:
- Run
npm install prisma --save-dev - Run
prisma initand write a model - Run
prisma migrate dev --name m1 --preview-feature
Expected behavior
I expect it to create a database table with Prisma Migrate. It does create the database, but not the table.
Prisma information
// .env
DATABASE_URL=mysql://username:password@hostname.rds.amazonaws.com:3306/dbname
// .schema.prisma
datasource db {
provider = "mysql"
url = env("DATABASE_URL")
}
generator client {
provider = "prisma-client-js"
}
model ModelName {
id Int @default(autoincrement()) @id
createdAt DateTime @default(now())
}
Environment & setup
- OS: Mac OS
- Database: MySQL
- Node.js version: v14.5.0
- Prisma version:
prisma : 2.16.1
@prisma/client : 2.16.1
Current platform : darwin
Query Engine : query-engine 8b74ad57aaf2cc6c155f382a18a8e3ba95aceb03 (at node_modules/@prisma/engines/query-engine-darwin)
Migration Engine : migration-engine-cli 8b74ad57aaf2cc6c155f382a18a8e3ba95aceb03 (at node_modules/@prisma/engines/migration-engine-darwin)
Introspection Engine : introspection-core 8b74ad57aaf2cc6c155f382a18a8e3ba95aceb03 (at node_modules/@prisma/engines/introspection-engine-darwin)
Format Binary : prisma-fmt 8b74ad57aaf2cc6c155f382a18a8e3ba95aceb03 (at node_modules/@prisma/engines/prisma-fmt-darwin)
Studio : 0.346.0
Issue Analytics
- State:
- Created 3 years ago
- Comments:24 (9 by maintainers)
Top Results From Across the Web
Error: P1001: Can't reach database server at `localhost`:`5200`
Localhost and the mapped port are used when connecting from the host machine. You're connecting from another container on the bridge network and ......
Read more >Troubleshooting for Amazon RDS - AWS Documentation
Amazon RDS insufficient DB instance capacity. The InsufficientDBInstanceCapacity error can be returned when you try to create, start, or modify a DB instance....
Read more >Resolve problems connecting to an Amazon RDS DB instance
You're using an incorrect user name or password at the database level to access the instance from the DB client. You don't have...
Read more >Troubleshoot Access Denied error in Amazon RDS for MySQL
IAM authentication is turned off ; Insufficient IAM role permissions; Database user is improperly configured; Incorrect connection string ...
Read more >Help wanted: Error: P1001: Can't reach database server at "db ...
Could it be a certificate issue? I've seen others mention that it might be that the postgres port has switched to 5433 but...
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 Free
Top 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

I found the problem, this was due to the AWS RDS server latency is high (in different region than my location). See https://www.prisma.io/docs/concepts/database-connectors/mysql#arguments
Solution: Add
?connect_timeout=30&pool_timeout=30&socket_timeout=30(or higher seconds) toDATABASE_URL@janpio everything is working well with the SSL, thanks for your reply!