无法连接到postgres实例

时间:2017-08-27 10:06:06

标签: node.js postgresql google-cloud-sql

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

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

但每次我尝试发出请求时,Knex都会返回此消息:

  

Knex:超时获取连接。游泳池可能已满。你错过了.transacting(trx)电话吗?

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

1 个答案:

答案 0 :(得分:0)

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

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

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