无法从 google 个应用引擎节点连接到云 sql 中的 postgres
Unable to connect to postgres in cloud sql from google app engine nodes
我正在开发 nodejs 和 postgres 应用程序。两者都部署在 google。我的 postgres 在 google 云 sql 中,nodejs 部署在 google 应用程序引擎中。我正在尝试从 nodejs 连接到 postgres,但它抛出无法连接到云 postgres。我已经更新了 app.yml 文件并且我使用的是普通的 pg 客户端而不是 knex。谁能帮我。我的配置如下
const client = new Client({
user: 'postgres',
host:'xx.xx.xx.xx',
socketpath: '/cloudsql/proj-name:us-central1:app-name',
database: 'xxxxx',
password: 'xxxx',
port: 5432,
ssl: true,
});
client.connect();
我试过没有套接字路径和主机。什么都不管用。所有这一切在我的本地机器上运行良好,我已经将我的本地 public ip.Any 列入白名单,我们将不胜感激。
我收到错误
(node:16) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: connect ETIMEDOUT xx.xx.xx.xx:5432
更改为以下配置有效。
const client = new Client({
user: 'postgres',
host: '/cloudsql/proj-name:us-central1:app-name',
database: 'xxxxx',
password: 'xxxx',
port: 5432
});
client.connect();
我正在开发 nodejs 和 postgres 应用程序。两者都部署在 google。我的 postgres 在 google 云 sql 中,nodejs 部署在 google 应用程序引擎中。我正在尝试从 nodejs 连接到 postgres,但它抛出无法连接到云 postgres。我已经更新了 app.yml 文件并且我使用的是普通的 pg 客户端而不是 knex。谁能帮我。我的配置如下
const client = new Client({
user: 'postgres',
host:'xx.xx.xx.xx',
socketpath: '/cloudsql/proj-name:us-central1:app-name',
database: 'xxxxx',
password: 'xxxx',
port: 5432,
ssl: true,
});
client.connect();
我试过没有套接字路径和主机。什么都不管用。所有这一切在我的本地机器上运行良好,我已经将我的本地 public ip.Any 列入白名单,我们将不胜感激。
我收到错误
(node:16) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: connect ETIMEDOUT xx.xx.xx.xx:5432
更改为以下配置有效。
const client = new Client({
user: 'postgres',
host: '/cloudsql/proj-name:us-central1:app-name',
database: 'xxxxx',
password: 'xxxx',
port: 5432
});
client.connect();