【问题标题】:Couldn't connect to postgres instance无法连接到 postgres 实例
【发布时间】:2017-08-27 21:31:28
【问题描述】:

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

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

但每次我尝试提出请求时,Knex 总是返回此消息:

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

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

【问题讨论】:

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


    【解决方案1】:

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

    驱动支持的完整语法是:

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

    【讨论】:

    • 我的配置是正确的,不过我按照 gcloud 网站上的教程进行操作。我发现问题是我没有启用 SQL 服务。还是谢谢你的回答
    猜你喜欢
    • 2020-01-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-03-23
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多