运行下面的代码并尝试为我的应用程序创建注册数据时,我收到一个奇怪的错误。任何人都可能知道这里发生了什么事情?
Unhandled rejection SequelizeConnectionRefusedError: connect ECONNREFUSED 127.0.0.1:5432
at C:\Users\HP\Desktop\bro\node_modules\sequelize\lib\dialects\postgres\connection-manager.js:170:24
at Connection.connectingErrorHandler (C:\Users\HP\Desktop\bro\node_modules\pg\lib\client.js:213:14)
at Connection.emit (events.js:315:20)
at Socket.reportStreamError (C:\Users\HP\Desktop\bro\node_modules\pg\lib\connection.js:57:10)
at Socket.emit (events.js:315:20)
at emitErrorNT (internal/streams/destroy.js:84:8)
at processTicksAndRejections (internal/process/task_queues.js:84:21)
User.js
var User = sequelize.define('User', {
name: {
type: String,
required: true
},
email: {
type: String,
required: true
},
password: {
type: String,
required: true
},
date: {
type: Date,
default: Date.now
}
});
sequelize.sync().then(function () {
User.create({
name: 'Steve',
email: 'email@gmail.com',
password: '123123',
date: 02/1/2020
})
});
答案 0 :(得分:0)
当sequelize无法与您的数据库建立连接时,将出现此错误。您可以检查您的数据库是否正在指定的主机和端口上运行吗?
答案 1 :(得分:0)
您没有启动数据库或错误的数据库配置,请检查数据库配置:var sequelize = new Sequelize()或启动数据库