我想連接到我本地的postgres數據庫與knex,但我不斷收到此錯誤。連接到本地主機上的postgresql與knex時出現錯誤
{ Error: connect ECONNREFUSED 127.0.0.1:5432
at Object.exports._errnoException (util.js:1022:11)
at exports._exceptionWithHostPort (util.js:1045:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1090:14)
code: 'ECONNREFUSED',
errno: 'ECONNREFUSED',
syscall: 'connect',
address: '127.0.0.1',
port: 5432 }
// Here is how everything is set up:
const connection = require('./db/knexfile.js').development;
const knex = require('knex')(connection);
const app = express();
const server = app.listen(PORT, '127.0.0.1', 'localhost',() => console.log(`Listening on ${ PORT }`));
// Inside knexfile.js
module.exports = {
development: {
client: 'pg',
connection: {
"user": "development",
"password": "development",
"database": "testdb",
"host": "127.0.0.1",
"port": 5432
},
pool: {
min: 2,
max: 10
},
migrations: {
tableName: 'knex_migrations'
}
}
};
其他信息: 我也運行過的WebPack在localhost陣營前端:3000穿過的WebPack服務器上的代理服務器設置發送HTTP請求到8080,但這似乎是工作。
我也有在localhost上運行的elasticsearch:9200,而且這似乎也是一樣。