【发布时间】:2017-02-02 21:00:52
【问题描述】:
我正在尝试使用 knex 连接到我的本地 postgres 数据库,但我不断收到此错误。
{ 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'
}
}
};
附加信息: 我还在 localhost:3000 上通过 webpack 运行 React 前端,它通过 webpack 服务器上的代理设置将 http 请求发送到 8080,但这似乎工作正常。
我还在 localhost:9200 上运行了 elasticsearch,这似乎也在工作。
【问题讨论】:
标签: node.js postgresql express localhost knex.js