Connection error on tring to connect to mssql 2019 db running in a docker container
const sql = require('mssql');
async function connectdb() {
const config = {
user: 'SA',
password: 'password',
server: 'container_name',
database: 'database_name',
};
try{
const connection = await sql.connect(config);
console.log('Connected to the database!');
}
catch(err){
console.error('Error connecting to the database:', err)
}
}
connectdb()
Expected behaviour: "Connected to db" logged to the console.
Actual behaviour: "Error connecting to the database: ConnectionError: Failed to connect to container_name:1433 - getaddrinfo EAI_AGAIN container_name" logged to the console