Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to connect to SQL Server 2019 Express with Tedious - but able to connect with SQLCMD #1507

Open
YoricWatterott opened this issue Dec 15, 2022 · 3 comments

Comments

@YoricWatterott
Copy link

Hi there,

I have tried using the default connection example but I am getting an error saying not found
Eventhough using SQLCMD in powershell i get a connection with the same credentials:

`PS C:\Users\Yoric> sqlcmd -S localhost\SQLExpress -U sa -P test -d testDB -Q "SELECT @@Version"

Microsoft SQL Server 2019 (RTM) - 15.0.2000.5 (X64)
Sep 24 2019 13:48:23
Copyright (C) 2019 Microsoft Corporation
Express Edition (64-bit) on Windows 10 Pro 10.0 (Build 22000: ) (Hypervisor)
(1 rows affected)`


Here is my node code with the same credentials ("tedious": "^15.1.2"):

`var Connection = require('tedious').Connection;

var config = {
server: "localhost\SQLEXPRESS",
options: {
database: 'testDB'
},
authentication: {
type: "default",
options: {
userName: "sa",
password: "test"
}
}
};

var connection = new Connection(config);

// Setup event handler when the connection is established.
connection.on('connect', function(err) {
if(err) {
console.log('Error: ', err)
} else {
// If no error, then good to go...
console.log("Connected");
}
});

// Initialize the connection.
connection.connect();`


Here is the error I get:

`Error: Failed to connect to localhost\SQLEXPRESS:1433 - getaddrinfo ENOTFOUND localhost\SQLEXPRESS
at Connection.socketError (c:\Users\Yoric\Documents\1.

Work\Workbench\Node\SQLExpress\node_modules\tedious\lib\connection.js:1395:28)
at c:\Users\Yoric\Documents\1. Work\Workbench\Node\SQLExpress\node_modules\tedious\lib\connection.js:1176:14
at processTicksAndRejections (node:internal/process/task_queues:78:11) {code: 'ESOCKET', isTransient: undefined, stack: 'Error:

Failed to connect to localhost\SQLEXPR…ons (node:internal/process/task_queues:78:11)', message: 'Failed to connect to localhost\SQLEXPRESS:14…- getaddrinfo ENOTFOUND localhost\SQLEXPRESS'}`

So it's not even saying refused, just not found, which seems odd to me because SQLCMD can see it just fine


Here is what I have tried:

I have tried the connection example in "mssql": "^9.0.1" as well, I get the same error.

My concurrent connection limit is set to infinite, the default.

I can log in to my SSMS just fine with the same credentials.

I can connect to my DB externally using SQLCMD commands in Powershell with the same credentials.


I am at my wit's end, and I feel like I'm crazy,
Can anyone help me figure out what is wrong in my environment, please?

Thank you for your time

@mShan0
Copy link
Contributor

mShan0 commented Dec 15, 2022

Hi @YoricWatterott, can you try setting your server to simply localhost? I.e. server:"localhost". Tedious doesn't support the <instancename> format.

Can you also double check that your database is configured to accept TCP/IP connections? You can do so in the SQL Server Configuration Manager.

If you have to set the instance name, you can use options.instanceName to do so. There is more information on this in our docs which can be found here: https://tediousjs.github.io/tedious/api-connection.html

@pbarbiero
Copy link

@mShan0 instead of opening a new ticket, maybe it fits here.

The repo advertises TDS 7.4 (SQL Server 2012/2014/2016/2017) -- is 2019 supposed to be supported or being worked on? My business is currently scoping upgrading our DB from 2016 to 2019, maybe even newer. This is one of the few things I have found when searching that seems to state interfacing with SQL Server 2019 is expected to work.

@MichaelSun90
Copy link
Contributor

Hi @pbarbiero, TDS 7.4 is supported by Microsoft SQL Server 2019. You can check the list of corresponding TDS versions and SQL server versions that supports them here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants