无法使用 aws-rds url 到达 `postgres`:`5432` 处的数据库服务器

问题描述 投票:0回答:1

我使用的技术:

  • nextJS;
  • 棱镜;
  • postgresql;
  • 码头工人;

我正在尝试通过传递此网址来连接到数据库:

DATABASE_URL="postgresql://USER:PASSWORD@HOST:5432"

它是一个 AWS RDS Postgres 数据库,我确信它工作正常,因为我可以手动连接到它。

schema.prisma:

generator client {
  provider = "prisma-client-js" 
}

datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
}

完整错误日志:

next-1   | Failed to sync db: getaddrinfo EAI_AGAIN postgresdb
next-1   | prisma:error 
next-1   | Invalid `prisma.user.findUnique()` invocation:
next-1   | 
next-1   | 
next-1   | Can't reach database server at `postgres`:`5432`
next-1   | 
next-1   | Please make sure your database server is running at `postgres`:`5432`.
next-1   | ERR Error: 
next-1   | Invalid `prisma.user.findUnique()` invocation:
next-1   | 
next-1   | 
next-1   | Can't reach database server at `postgres`:`5432`
next-1   | 
next-1   | Please make sure your database server is running at `postgres`:`5432`.
next-1   |     at RequestHandler.handleRequestError (/app/node_modules/@prisma/client/runtime/index.js:31955:13)
next-1   |     at RequestHandler.handleAndLogRequestError (/app/node_modules/@prisma/client/runtime/index.js:31913:12)
next-1   |     at /app/node_modules/@prisma/client/runtime/index.js:32458:25
next-1   |     at async PrismaClient._executeRequest (/app/node_modules/@prisma/client/runtime/index.js:33022:22)
next-1   |     at async PrismaClient._request (/app/node_modules/@prisma/client/runtime/index.js:32994:16)
next-1   |     at async Object.createUser (/app/.next/server/pages/api/graphql.js:1:15549)
next-1   |     at async Object.signup (/app/.next/server/pages/api/graphql.js:1:2170)
next-1   |     at async file:///app/node_modules/@envelop/core/esm/orchestrator.js:373:27
next-1   |     at async YogaServer.getResultForParams (file:///app/node_modules/graphql-yoga/esm/server.js:270:26)
next-1   |     at async YogaServer.getResponse (file:///app/node_modules/graphql-yoga/esm/server.js:336:23) {
next-1   |   path: [ 'signup' ],
next-1   |   locations: [ { line: 8, column: 5 } ],
next-1   |   extensions: [Object: null prototype] {}
next-1   | }

我也尝试使用这些网址运行:

DATABASE_URL="postgresql://USER:PASSWORD@HOST:5432/postgres

DATABASE_URL="postgresql://USER:PASSWORD@HOST:5432/postgres?connect_timeout=300"
DATABASE_URL="postgresql://USER:PASSWORD@HOST:5432/postgres?schema=public"
postgresql docker next.js amazon-rds prisma
1个回答
0
投票

您是否尝试过使用:postgres://USER:PASSWORD@HOST:5432/postgres?

© www.soinside.com 2019 - 2024. All rights reserved.