First of all I would assume here that you are using tedious module (by looking at the comment of options.encrypt). I wanted to confirm this first with comment but I lack credits to comment. I really wanted to help you because I faced the exact same issue sometime back, so here it goes.
I'll divide your questions in two parts in the context of Nodejs Tedious module.
- Support for Named Instances
- Support for Windows Authentication
Support for Named Instances
By default tedious uses server and options.port to connect. options.port is the default setting with a default value of 1433. This is the reason configuration mentioned below worked.
var webconfig = {
user: 'sa',
password: 'aman',
server: '192.5.5.62',
database: 'Demo',
options: {
encrypt: false // Use this if you're on Windows Azure
}
}
But if you want to use named instances in the connection configuration, then you must use options.instanceName as shown below. See the documentation.
var webconfig = {
user: 'sa',
password: 'aman',
server: 'Aman', //FQDN is preferred, so assuming you can ping this
database: 'Demo',
options: {
instanceName: 'AMAN'
encrypt: false // Use this if you're on Windows Azure
}
}
In your case, however it isn't required to connect using named instance because you are able to connect using hostname\IP itself.
Also, you could either use options.port or options.instanceName but not both in the configuration at a time.
This brings me to your second question.
Support for Windows Authentication
Tedious module do not support Windows Authentication to connect to SQL Server instances currently. See here. However, there are few bright minds who already are working on it. Look at this open PR #497. Feel free to contribute to the Tedious community.
BONUS TIP: Going forward, instead of guessing the root cause, you could also make use of debug event by tedious module which will route you in the right direction. Make sure to disable it in production.
Please mark this as an answer if it helped you. Cheers!