无法连接到 postgres 实例

Couldn't connect to postgres instance

我制作了一个 nodejs 应用程序,现在我想将它部署到 Google 云端,但我无法成功连接到 PostgresQL。我在同一项目上部署的应用程序和 Postgres 实例 运行,我使用此连接字符串:

pg://postgres:[password]@/[db_name]?host=/cloudsql/[Instance_name_of_Postgres]

但每次我尝试发出请求时,Knex 总是 return 此消息:

Knex: Timeout acquiring a connection. The pool is probably full. Are you missing a .transacting(trx) call?

在我的开发机器中,我允许 IP 地址并使用该连接字符串和服务器 ip 连接到 Postgres 实例,但有任何问题。

您的连接字符串不正确,不是@/[db_name]?host,而是@host/db_name

驱动程序支持的完整语法是:

postgres://username:password@host:port/database?ssl=false&application_name=name
&fallback_application_name=name&client_encoding=encoding