tediousjs / node-mssql

Microsoft SQL Server client for Node.js
https://tediousjs.github.io/node-mssql
MIT License
2.23k stars 465 forks source link

Issue connecting to db with both named instance and port defined #1492

Closed edgwatson1 closed 1 year ago

edgwatson1 commented 1 year ago

Expected behaviour:

I'm connecting to a db using a node app. Node app will connect fine for most dbs. However, I'm having an issue with a db that has both the named instance and port defined, but can't find a way to connect using mssql. I can connect to db directly using SSMS.

I notice in the docs it suggests the two are incompatible: 'port - Port to connect to (default: 1433). Don't set when connecting to named instance.'

Right now I'm doing something like this:

const sqlConfig = { user: process.env.user, password: process.env.password, database: process.env.dbname, server: 'servername.com/namedinstance01', pool: { max: 10, min: 0, idleTimeoutMillis: 30000 }, options: { port: 01234 } }

Actual behaviour:

I would expect to be able to connect using this named instance + port, but I get a connection error

Software versions

Is it possible to connect to a db defined with both named instance and port?

edgwatson1 commented 1 year ago

Closed, issue was faulty. Port was mapped onto instance name, so defining both was unnecessary.