【问题标题】:Unable to connect to Cloud Sql (postgres) from firebase function无法从 firebase 函数连接到 Cloud Sql (postgres)
【发布时间】:2018-12-23 05:36:27
【问题描述】:

我正在使用 nodejs firebase 函数。我使用sequlize 连接到postgres 数据库。

我尝试按照文档 https://cloud.google.com/functions/docs/sql 从 firebase 函数连接到数据库,但我无法连接。我收到此错误。

Failed to prune sessions: connect ECONNREFUSED 127.0.0.1:5432

这是我使用的配置。

{ username: 'postgres',
    password: '*********',
    database: 'testdb',
    host: '/cloudsql/my-project:us-central1:db-instance',
    port: 5432,
    dialect: 'postgres',
    dialectOptions: { ssl: false }}

有什么想法吗?

【问题讨论】:

  • 我对sequlize一无所知,但我会问你是否确定主机字符串是正确的?有东西试图连接到本地 Cloud Functions 实例,这显然是不对的。
  • @DougStevensonn 感谢您的提示。我把它修好了。顺便说一句,火基颂歌很棒:)

标签: firebase google-cloud-functions google-cloud-sql


【解决方案1】:

我的错。我也在使用pg session,它使用的是连接字符串。我猜 pg 无法区分主机和连接字符串。

用 pg 池对象替换连接字符串后,我能够连接。

【讨论】:

    猜你喜欢
    • 2020-01-27
    • 2022-01-24
    • 2021-06-18
    • 1970-01-01
    • 2020-11-12
    • 2020-06-07
    • 1970-01-01
    • 2019-05-22
    • 2020-02-16
    相关资源
    最近更新 更多