简体   繁体   English

Prisma DB 无法连接到 AWS RDS

[英]Prisma DB Can't connect to AWS RDS

I have a nextjs project that's using prismaDB for the ORM. I'm able to connect just fine to my local postgres db but I'm getting this error when running npx prisma migrate .我有一个为 ORM 使用 prismaDB 的 nextjs 项目。我能够很好地连接到我的本地 postgres 数据库,但在运行npx prisma migrate时出现此错误。

Error: P1001: Can't reach database server at db-name.*.us-west-2.rds.amazonaws.com : 5432 .错误:P1001:无法访问位于db-name.*.us-west-2.rds.amazonaws.com数据库服务器: 5432

schema.prisma:架构.棱镜:

datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
  //url    = "postgresql://master_username:master_password@aws_host:5432/db_name"
}

The RDS db is currently public and I'm positive that I've copied over the RDS credentials correctly. RDS 数据库目前是公开的,我确信我已经正确地复制了 RDS 凭据。 There doesn't seem to be anything I should be including for the connection to work but I'm not getting any other info as to why I can't reach the db server.似乎没有任何我应该包含的连接才能正常工作,但我没有得到关于为什么我无法连接到数据库服务器的任何其他信息。

Seems like you have to replace db-name.*.us-west-2.rds.amazonaws.com with the name of your actual database, unless you replaced it for the purpose of asking this question.似乎您必须将db-name.*.us-west-2.rds.amazonaws.com替换为实际数据库的名称,除非您是为了提出这个问题而替换它。 Specifically the part where it says db-name.* .特别是它所说的部分db-name.*

Docs: https://www.prisma.io/docs/reference/api-reference/error-reference#common文档: https://www.prisma.io/docs/reference/api-reference/error-reference#common

P1001 indicates that it couldn't find the database given the connection string, NOT necessarily that the credentials you provided were wrong. P1001表示它找不到给定连接字符串的数据库,不一定是您提供的凭据有误。 Make sure you're specifying the correct database name/host and whatever else you need to make it work for AWS.确保您指定了正确的数据库名称/主机以及使其适用于 AWS 所需的任何其他内容。

Somehow I was able to connect to RDS after deleting and creating a new DB for the third time.在第三次删除和创建新数据库后,我以某种方式能够连接到 RDS。 I confirmed connection through pgAdmin then tried it again my app deployed to vercel.我通过 pgAdmin 确认连接然后再次尝试我的应用程序部署到 Vercel。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM