I'm trying to connect to a remote SQL Server from my machine, I'm working with node. I can connect to it through SQL Management Studio, and I could connect with a C# application as well (both using Windows Authentication). I've already searched in several forums (in some questions here as well) and couldn't find a solution.
Below you can find the error I got:
message: 'Failed to connect to MyServer:1433 - getaddrinfo ENOTFOUND MyServer',
code: 'ESOCKET' },
name: 'ConnectionError' }
This is the code I'm using:
'use strict';
var http = require('http');
var express = require('express');
var port = process.env.PORT || 1337;
var app = express();
app.get('/', (req, resp) => {
var sql = require("mssql");
var config = {
driver: 'msnodesqlv8',
server: 'MyServer/Instance',
database: 'MyDB',
options: {
trustedConnection: true
}
};
sql.connect(config, (error) => {
if (error)
console.log(error);
var request = new sql.Request();
request.query('select * from MyTable', (err, recordset) => {
if (err)
console.log(err);
resp.send(recordset);
});
});
});
var servidor = app.listen(port, function () {
console.log("Server running");
});
I looked other questions (here and here for example), but no luck.