I want to use a mssql database for my project. I took the node-mssql module (https://www.npmjs.com/package/mssql) and for the database management I use Microsoft SQL Server Management Studio 17.
When executing some queries I don't want to connect to the database multiple times so I want to create a pool to have a permanent connection to the database.
My database manager module:
const sql = require('mssql');
const db = require('../config/database.js');
const pool = new sql.ConnectionPool(db).connect();
My database configuration:
module.exports = {
user: process.env.DB_USER || 'sa',
password: process.env.DB_PASS || '-- myPassword --',
server: process.env.DB_SERVER || 'localhost',
database: process.env.DB || 'local_demo_cobra',
};
MSSQL Studio I changed the authentication mode to SQL Server Authentication
and here you can see the database managed by the server
When trying to run the code I get the error
ConnectionError: Failed to connect to localhost:1433 - Could not connect (sequence)
The database is running on my own system so using localhost should be fine. I also tried to change the server configuration to
server: process.env.DB_SERVER || 'localhost\\AP-MHERMSEN',
but this throws the same error
ConnectionError: Failed to connect to localhost\AP-MHERMSEN
What is wrong or missing?

