Tedious: Cannot connect to localhost/sqlexpress

Created on 30 Oct 2013  路  2Comments  路  Source: tediousjs/tedious

When setting the server to sqlexpress on localhost I get the exeption: getaddrinfo ENOTFOUND

var config = {
    userName: 'sa',
    password: 'mypassword',
    server: 'localhost/sqlexpress'
    server: 'LOCALHOST\\sqlexpress'
    server: 'LOCALHOST/SQLEXPRESS'
    server: 'LOCALHOST\\SQLEXPRESS'
    // note: I only use one of these at a time
  };

If it helps, when setting the server to just localhost I instead get a ECONNREFUSED.

Is there a problem in the lookup fo localhost\sqlexpress?

Most helpful comment

Ok, thank you!

I couldn't get the configurations right on my sql server for options.instanceName to work but I set it up so that my named sqlexpress instance responded to port 1433 and then it sufficed with server: 'localhost' to connect.

If anybody else stumble upon this problem Zasz's answer on SO explains how to configure this: http://stackoverflow.com/questions/35026/sql-server-convert-a-named-instance-to-default-instance

All 2 comments

Microsoft style strings of hostname\instancename are not supported.

The server value must be a hostname (that can be resolved to an ip address) or an ip address. Pretty much the first thing that tedious will do when creating a connection is to open a tcp connection to the server on port 1433 (default). So all that is need is needed is a hostname (or ipaddress) and an optional port.

The sql server instance must be configured to accept tcp connections on port 1433 (or other port of your choice).

An alternative to knowing the port is to specify a value for options.instanceName (see http://pekim.github.io/tedious/api-connection.html#function_newConnection), but support for this may be more complicated to configure on the server.

Ok, thank you!

I couldn't get the configurations right on my sql server for options.instanceName to work but I set it up so that my named sqlexpress instance responded to port 1433 and then it sufficed with server: 'localhost' to connect.

If anybody else stumble upon this problem Zasz's answer on SO explains how to configure this: http://stackoverflow.com/questions/35026/sql-server-convert-a-named-instance-to-default-instance

Was this page helpful?
0 / 5 - 0 ratings