0
在heroku上有一個節點應用程序,嘗試使用node-postgres和heroku-postgres連接到postgres。節點應用程序中的Heroku-Postgres連接字符串
const {Pool} = require('pg');
var connectionString = process.env.DATABASE_URL || {user:'bot',database:'myDB'};
const db = new Pool(connectionString);
console.log('Starting DB with parameters: '+connectionString);
從
$ heroku log
Heroku的日誌顯示的Heroku生成的連接字符串設置:
2017-09-08T00:36:03.510529+00:00 app[web.1]: Starting DB with parameters: postgres://xxxxxx:[email protected]:5432/xxxxxxxx
但實際的查詢率:
2017-09-08T00:36:04.794422+00:00 app[web.1]: Error executing query Error: connect ECONNREFUSED 127.0.0.1:5432
2017-09-08T00:36:04.794425+00:00 app[web.1]: at Object.exports._errnoException (util.js:1020:11)
2017-09-08T00:36:04.794426+00:00 app[web.1]: at exports._exceptionWithHostPort (util.js:1043:20)
2017-09-08T00:36:04.794426+00:00 app[web.1]: at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1086:14)
這意味着連接字符串沒有被設置因爲它似乎是。 。 。 是這樣嗎?如果是這樣,爲什