question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Trouble connecting to SQL server (SQL instance name missing)

See original GitHub issue

Hi I am having troubles connecting to SQL server

My MSSQL version is 12.0.2000.8 (SQL Server 2014, local instance not azure)

My code is mostly just from examples

var sql = require('mssql');

var config = {
    user: 'devuser',
    password: 'devuser',
    server: 'GRIFF\\SQLEXPRESS',
    database: 'devdb',
    port: 1433,
    debug: true,
    options: {
        encrypt: false // Use this if you're on Windows Azure
    }
}

var connection = sql.connect(config, function(err) {

    console.log(err);

    var tpl = 'insert into Users (DisplayName, Email) values ("@displayName", "@email")';
    var ps = new sql.PreparedStatement(connection);
    ps.input('displayName', sql.NVarChar(255));
    ps.input('email', sql.NVarChar(255));
    ps.prepare(tpl, function(err) {

        console.log(err);

        var user = {
            displayName: 'Jim',
            email: 'jim@panse.de'
        };

        ps.execute(user, function(err, recordset) {

            console.log(err);
            console.log(recordset);

            ps.unprepare(function(err) {

                console.log(err);
            });
        });
    });
});

I get following response

{ [ConnectionError: Failed to connect to GRIFF:undefined in 15000ms]
  name: 'ConnectionError',
  message: 'Failed to connect to GRIFF:undefined in 15000ms',
  code: 'ETIMEOUT' }

C:\Temp\mssqlfoo\node_modules\mssql\lib\main.js:583
        this.connection.pool.acquire(done);
                             ^
TypeError: Cannot call method 'acquire' of null
    at PreparedStatement._prepare (C:\Temp\mssqlfoo\node_modules\mssql\lib\main.js:583:30)
    at PreparedStatement.prepare (C:\Temp\mssqlfoo\node_modules\mssql\lib\main.js:513:21)
    at C:\Temp\mssqlfoo\sql.js:22:5
    at C:\Temp\mssqlfoo\node_modules\mssql\lib\main.js:268:20
    at C:\Temp\mssqlfoo\node_modules\mssql\lib\tedious.js:394:20
    at C:\Temp\mssqlfoo\node_modules\mssql\node_modules\generic-pool\lib\generic-pool.js:274:11
    at Connection.<anonymous> (C:\Temp\mssqlfoo\node_modules\mssql\lib\tedious.js:347:26)
    at Connection.g (events.js:180:16)
    at Connection.emit (events.js:95:17)
    at Connection.connectTimeout (C:\Temp\mssqlfoo\node_modules\mssql\node_modules\tedious\lib\connection.js:709:10)

Content of mssql_debug_1429881975435.log

Failed to connect to GRIFF:undefined in 15000ms

That GRIFF:undefined thing looks pretty wrong, the SQL instance name is missing. Do I do something wrong here?

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:11

github_iconTop GitHub Comments

10reactions
tracker1commented, Apr 24, 2015

@aruss according to tedious docs on the connection api

var config = {
    user: 'devuser',
    password: 'devuser',
    server: 'GRIFF',
    database: 'devdb',
    port: 1433,
    debug: true,
    options: {
        encrypt: false // Use this if you're on Windows Azure
        ,instanceName: 'SQLEXPRESS'
    }
}
6reactions
malcolmswainecommented, Dec 29, 2015

Make sure that the SQL Server Browser Service is running. Turning it off will cause this error to be raised.

capture

Read more comments on GitHub >

github_iconTop Results From Across the Web

A network-related or instance-specific error occurred - SQL ...
To connect to a named instance, the SQL Server Browser service must be running. In SQL Server Configuration Manager, locate the SQL Server ......
Read more >
Resolving could not open a connection to SQL Server errors
Check to see if allow remote connections for this server is enabled. In SSMS, right click on the instance name and select Properties....
Read more >
SQL Server Express Instance is not showing while ...
Typically, the SQL Express instance is named SQLEXPRESS, so unless you changed this during installation, you need to change the instance ...
Read more >
SSMS Server Name Not Showing | Fixed - YouTube
SQL Server Management Studio not showing Server name to establish connection | Fixed Reason: SSMS is the tool used to connect...
Read more >
Unable to get database list. An unexpected fatal exception ...
The Microsoft SQL Server installation is not complete. In some cases, the instance name is missing in the Connection Properties window in ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found