Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/477.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 指定parameters对象时,postgresql连接到我的数据库的方式是否有问题?_Javascript_Node.js_Postgresql - Fatal编程技术网

Javascript 指定parameters对象时,postgresql连接到我的数据库的方式是否有问题?

Javascript 指定parameters对象时,postgresql连接到我的数据库的方式是否有问题?,javascript,node.js,postgresql,Javascript,Node.js,Postgresql,我正在使用node.js连接到我的postgres数据库 我正在更改创建到postgres数据库的连接的方式,以指定最大连接数 这是现有的代码:(我已经用user和password替换了实际的用户/密码;db名称与用户相同) 其中DATABASE\u URL\u FULL=postgres://user:password@manny.db.elephantsql.com:5432/user 这个很好用。但是,当我使用此选项时: // Load and initialize pg-promise:

我正在使用node.js连接到我的postgres数据库

我正在更改创建到postgres数据库的连接的方式,以指定最大连接数

这是现有的代码:(我已经用user和password替换了实际的用户/密码;db名称与用户相同)

其中
DATABASE\u URL\u FULL=postgres://user:password@manny.db.elephantsql.com:5432/user

这个很好用。但是,当我使用此选项时:

// Load and initialize pg-promise:
const pgp = require('pg-promise')(initOptions);

// Connection parameters
const cn = {
    host: process.env.DATABASE_URL,
    port: process.env.DATABASE_PORT,
    database: process.env.DATABASE_NAME,
    user: process.env.DATABASE_USER,
    password: process.env.DATABASE_PASSWORD,
    max: process.env.DATABASE_MAX_CON,
    idleTimeoutMillis: process.env.DATABASE_IDLE_TIMEOUT
};

// Create the database instance:
const db = pgp(cn);
其中
DATABASE\u URL=manny.db.elephantsql.com
我得到这个错误:

Unhandled rejection Error: getaddrinfo ENOTFOUND postgres://manny.db.elephantsql.com postgres://manny.db.elephantsql.com:5432
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:56:26)

非常感谢

好的,我注意到虽然我已经将环境变量设置为
manny.db.elephantsql.com
,但它仍然在使用
postgres://manny.db.elephantsql.com
这很奇怪。我清除了环境变量,重新启动,然后再次设置它们。现在它正在我的开发机器上工作(使用elephantsql url)-下一步,在我的GCP实例中测试它。好的,我注意到虽然我已经将环境变量设置为
manny.db.elephantsql.com
,但它仍然在使用
postgres://manny.db.elephantsql.com
这很奇怪。我清除了环境变量,重新启动,然后再次设置它们。现在它正在我的开发机器上工作(使用elephantsql url)-下一步,在我的GCP实例中测试它。
Unhandled rejection Error: getaddrinfo ENOTFOUND postgres://manny.db.elephantsql.com postgres://manny.db.elephantsql.com:5432
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:56:26)