'Unable to connect to Database through Sequelize where as Tedious is making a successful Database connection

I am trying to connect to Database for which I have used Sequelize. Below is the code of Sequelize

const Sequelize = require('sequelize');

var sequelize = new Sequelize(process.env.DB_NAME, process.env.DB_USER, process.env.DB_PASS, {
    host: process.env.DB_HOST,
    dialect: 'mssql',
    port:1433,
    dialectOptions: { 
      encrypt: true 
    },
    pool: {
      max: 5,
      min: 0,
      idle: 10000
    },
  });

sequelize
  .authenticate()
  .then(() => {
    console.log('Connection has been established successfully.');
  })
  .catch(err => {
    console.error('Unable to connect to the database:', err);
  });

This code was working fine before, but dont know why it suddenly stopped working and giving me the below error

ConnectionError [SequelizeConnectionError]: Failed to connect to ##### in 15000ms

Where as if I try with tedious I am able to connect to Database successfully. Below is my tedious code

const { Connection, Request } = require("tedious");

const config = {
    authentication: {
      options: {
        userName: process.env.DB_USER, 
        password: process.env.DB_PASS 
      },
      type: "default"
    },
    server: process.env.DB_HOST,
    options: {
        database: process.env.DB_NAME,
        port: 1433, 
        encrypt: true
      }
    };
    const connection = new Connection(config);

connection.on("connect", err => {
  if (err) {
    console.error(err.message);
  } else {
    console.log('DB connection is success')
  }
});

connection.connect();

Why am I not able to connect to database with Sequelize all of a sudden is my doubt. Can anyone please help me.

Thank you



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source