1

I am trying to connect to sql server from node.js like so -

const sql = require('mssql')

const pool = new sql.ConnectionPool({
  database: 'db',
  server: 'name',
  port: 41041,
  driver: 'msnodesqlv8',
  options: {
    trustedConnection: true,
    integratedSecurity: true
  }
})

pool.connect().then(() => {
  //simple query
  pool.request().query('select top 10 * from sync', (err, result) => {
        console.dir(result)
    })
})

But it is giving me this error - ConnectionError: Failed to connect to name:41041 in 15000ms at Connection.tedious.once.err

I am successfully able to connect via ssms like so name, 41041. Maybe it is unable to connect because it is using name: 41041. Any ideas on how to fix this?

James A Mohler
  • 11,060
  • 15
  • 46
  • 72
Doe
  • 379
  • 3
  • 14
  • 1
    Port 41041 is an usual port, are you sure that this the one you should be using? – James A Mohler Nov 06 '18 at 22:52
  • 1
    Yes, I can connect to `name, 41041` via ssms and pyodbc no problem – Doe Nov 06 '18 at 23:16
  • https://stackoverflow.com/questions/41477386/sql-server-connection-to-node-js and https://stackoverflow.com/questions/10309540/connect-to-sql-server-database-from-node-js – CR241 Nov 07 '18 at 00:12

0 Answers0