I am trying to follow Prisma's Start from Scratch guide for setting up a relational database with Node.js and MySQL. However, I encountered an error and I cannot connect to the database server.

Here are the details of the error:

  • Environment variables loaded from .env
  • Prisma schema loaded from prisma/schema.prisma
  • Datasource "db": MySQL database "test" at "gateway01.us-east-1.prod.aws.tidbcloud.com"

Error Message: Error: P1001: Can't reach database server at gateway01.us-east-1.prod.aws.tidbcloud.com:3306

I have double-checked my configurations and made sure all the necessary information is correct. However, I still cannot establish a connection to the database server.

Can anyone help me troubleshoot this issue or suggest potential solutions?

3

There are 3 best solutions below

0
On

It seems there may be a network restriction or firewall rule preventing your connection to the MySQL server. You can verify this by using the telnet command with the server's IP address and port number. If telnet fails to connect, check your network configuration and ensure the correct IP address and port number are used.

0
On

The default port of TiDB is 4000, not 3306.

0
On

realized you are using tidb, although it's mysql compatible the default configurations are quite different. They have a document about prisma and tidb. I was able to connect with the instructions. Maybe you can take a look at it https://docs.pingcap.com/tidb/stable/dev-guide-sample-application-nodejs-prisma