Node.JS on Google App Enging with Cloud SQLError: connect ENOENT /cloudsql/
Node.JS on Google App Enging with Cloud SQLError: connect ENOENT /cloudsql/
我已成功将我的应用程序部署到 Google App Engine。我的数据库已启动并且 运行 在云 SQL 上。通过在云 SQL 中的授权网络上将我的开发机器的 IP 列入白名单,我可以从我的本地机器毫无问题地连接到数据库。但是,当我部署到生产环境时,我得到:
Error: connect ENOENT /cloudsql/<my project id>:asia-south1:<my database instance name>
我的 app.yaml 文件如下所示:
runtime: nodejs
env: flex
manual_scaling:
instances: 1
resources:
cpu: 1
memory_gb: 0.5
disk_size_gb: 10
env_variables:
ST_ENV: 'Production' //Used to set the app listening on the below port
ST_PORT: '8080'
SQL_USER: '<username>'
SQL_PASSWORD: '<password>'
SQL_DATABASE: '<databasename>'
INSTANCE_CONNECTION_NAME: '/cloudsql/<my project id>:asia-south1:<my database instance name>'
beta_settings:
cloud_sql_instances: '<my project id>:asia-south1:<my database instance name>'
我的配置文件如下所示:
database: {
connectionLimit: 10,
// host : process.env.INSTANCE_CONNECTION_NAME,
socketPath: process.env.INSTANCE_CONNECTION_NAME,
user : process.env.SQL_USER,
password : process.env.SQL_PASSWORD,
database : process.env.SQL_DATABASE,
multipleStatements : true
}
我正在创建一个连接池(我已经简化了这个例子的代码):
var db = config.production.database;
var pool = mysql.createPool(db);
我已经能够通过本地 cloud_sql_proxy 从我的本地计算机成功连接。
我试过使用 Cloud SQL 实例的 IP 作为主机,但这给了我以下错误:
Error: connect ECONNREFUSED 127.0.0.1:3306'
我还尝试将主机指定为 0.0.0.0 和端口 3306 并得到:
Error: connect ECONNREFUSED 0.0.0.0:3306'
编辑:云 SQL 和云 SQL 管理 API 均已启用:
这就像在推送到生产环境时,应用引擎正在尝试使用不存在的代理。有人可以帮忙吗?
看看connecting from the Node.js runtime on App Engine Flexible. You can configure the connection using the instance connection name and some other environmental variables. It's not necessary to provide a host name or install the SQL proxy on your instance. Attempting to connect to the public IP of the Cloud SQL instance won't work from App Engine的具体说明。
我已成功将我的应用程序部署到 Google App Engine。我的数据库已启动并且 运行 在云 SQL 上。通过在云 SQL 中的授权网络上将我的开发机器的 IP 列入白名单,我可以从我的本地机器毫无问题地连接到数据库。但是,当我部署到生产环境时,我得到:
Error: connect ENOENT /cloudsql/<my project id>:asia-south1:<my database instance name>
我的 app.yaml 文件如下所示:
runtime: nodejs
env: flex
manual_scaling:
instances: 1
resources:
cpu: 1
memory_gb: 0.5
disk_size_gb: 10
env_variables:
ST_ENV: 'Production' //Used to set the app listening on the below port
ST_PORT: '8080'
SQL_USER: '<username>'
SQL_PASSWORD: '<password>'
SQL_DATABASE: '<databasename>'
INSTANCE_CONNECTION_NAME: '/cloudsql/<my project id>:asia-south1:<my database instance name>'
beta_settings:
cloud_sql_instances: '<my project id>:asia-south1:<my database instance name>'
我的配置文件如下所示:
database: {
connectionLimit: 10,
// host : process.env.INSTANCE_CONNECTION_NAME,
socketPath: process.env.INSTANCE_CONNECTION_NAME,
user : process.env.SQL_USER,
password : process.env.SQL_PASSWORD,
database : process.env.SQL_DATABASE,
multipleStatements : true
}
我正在创建一个连接池(我已经简化了这个例子的代码):
var db = config.production.database;
var pool = mysql.createPool(db);
我已经能够通过本地 cloud_sql_proxy 从我的本地计算机成功连接。
我试过使用 Cloud SQL 实例的 IP 作为主机,但这给了我以下错误:
Error: connect ECONNREFUSED 127.0.0.1:3306'
我还尝试将主机指定为 0.0.0.0 和端口 3306 并得到:
Error: connect ECONNREFUSED 0.0.0.0:3306'
编辑:云 SQL 和云 SQL 管理 API 均已启用:
这就像在推送到生产环境时,应用引擎正在尝试使用不存在的代理。有人可以帮忙吗?
看看connecting from the Node.js runtime on App Engine Flexible. You can configure the connection using the instance connection name and some other environmental variables. It's not necessary to provide a host name or install the SQL proxy on your instance. Attempting to connect to the public IP of the Cloud SQL instance won't work from App Engine的具体说明。