question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error P1001 Can't reach database server at AWS RDS (MySQL)

See original GitHub issue

Bug 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:

  1. Run npm install prisma --save-dev
  2. Run prisma init and write a model
  3. 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:closed
  • Created 3 years ago
  • Comments:24 (9 by maintainers)

github_iconTop GitHub Comments

26reactions
ceefourcommented, Mar 12, 2021

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) to DATABASE_URL

1reaction
armandoborgecommented, May 26, 2021

@janpio everything is working well with the SSL, thanks for your reply!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found