(node:4691) UnhandledPromiseRejectionWarning: SequelizeConnectionError: Connection terminated unexpectedly

Viewed 22

Thank you for taking a look at this

I created a database called wikistack, then try to connect it with sequelize , but this error,"SequelizeConnectionError: Connection terminated unexpectedly"

Inside app.js

const express = require('express');
const morgan = require('morgan');
const path = require('path');
const layout = require('./views/layout');
const { db } = require('./models');

const app = express();

app.use(morgan('dev'));
app.use(express.static(path.join(__dirname, 'public')));


db.authenticate()`enter code here`
  .then(() => {
    console.log('connected to the database');
  })

app.get('/',(req,res) =>{
    res.send(layout(""));
});

app.listen(1337,function(){
    console.log("You can do it!")
})

inside /models/index.js

const Sequelize = require('sequelize');
const db = new Sequelize('postgres://localhost:1337/wikistack');

module.exports = {
  db
}
0 Answers
Related