0

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

taep
  • 1
  • 2
  • Maybe [this helps](https://stackoverflow.com/questions/40182121/whats-the-cause-of-the-error-getaddrinfo-eai-again) – pierpy Jan 06 '23 at 06:57

0 Answers0