Node-mssql: Port for 'INSTANCE NAME' not found in localhost

Created on 28 Jan 2019  路  2Comments  路  Source: tediousjs/node-mssql

I am running Windows Server 2016 on a brand new EC2. I have enabled TCP/IP in the SQL Server Network Configuration

Expected behaviour:

I am using the sample promise code found here

Actual behaviour:

I get the following ConnectionError

{ ConnectionError: Port for EC2AMAZ-86TAJ27 not found in 127.0.0.1
    at Connection.tedious.once.err (C:\Users\Administrator\mssql-test\node_modules\mssql\lib\tedious.js:239:17)
    at Connection.g (events.js:291:16)
    at emitOne (events.js:96:13)
    at Connection.emit (events.js:188:7)
    at C:\Users\Administrator\mssql-test\node_modules\tedious\lib\connection.js:848:20
    at C:\Users\Administrator\mssql-test\node_modules\tedious\lib\instance-lookup.js:92:17
    at Socket.onMessage (C:\Users\Administrator\mssql-test\node_modules\tedious\lib\sender.js:141:9)
    at emitTwo (events.js:106:13)
    at Socket.emit (events.js:191:7)
    at UDP.onMessage (dgram.js:550:8)
  code: 'EINSTLOOKUP',
  originalError:
   { ConnectionError: Port for EC2AMAZ-86TAJ27 not found in 127.0.0.1
       at ConnectionError (C:\Users\Administrator\mssql-test\node_modules\tedious\lib\errors.js:12:12)
       at C:\Users\Administrator\mssql-test\node_modules\tedious\lib\connection.js:848:36
       at C:\Users\Administrator\mssql-test\node_modules\tedious\lib\instance-lookup.js:92:17
       at Socket.onMessage (C:\Users\Administrator\mssql-test\node_modules\tedious\lib\sender.js:141:9)
       at emitTwo (events.js:106:13)
       at Socket.emit (events.js:191:7)
       at UDP.onMessage (dgram.js:550:8)
     message: 'Port for EC2AMAZ-86TAJ27 not found in 127.0.0.1',
     code: 'EINSTLOOKUP' },
  name: 'ConnectionError' }

Configuration:

Here is the entire app.js

const sql = require('mssql')


const config = {
    user: 'Administrator',
    password: '',
    server: '127.0.0.1\\EC2AMAZ-86TAJ27', // You can use 'localhost\\instance' to connect to named instance
    database: 'mobss',


    options: {
        encrypt: false // Use this if you're on Windows Azure
    }
}

sql.connect(config).then(pool => {
    // Query

    return pool.request()
    .input('input_parameter', sql.Int, value)
    .query('select * from mytable where id = @input_parameter')
}).then(result => {
    console.log(result)

    // Stored procedure

    return pool.request()
    .input('input_parameter', sql.Int, value)
    .output('output_parameter', sql.VarChar(50))
    .execute('procedure_name')
}).then(result => {
    console.log(result)
}).catch(err => {
    console.log('logging err');
    console.log(err);
})

sql.on('error', err => {
    console.log('logging sql.on err');
    console.log(err);
})


I have tried omitting the instance name and using localhost instead of 127.0.0.1

Software versions

  • NodeJS: 6.9.1
  • node-mssql: 4.3.0
  • SQL Server: 2017 Developer Edition

Most helpful comment

The fix, for anyone interested;
https://github.com/tediousjs/node-mssql/issues/130#issuecomment-75596227

tl;dr - SQL Server Browser is not returning the server's port. Ensure TCP/IP is turned on via Network Configuration and restart both the server and browser instances.

All 2 comments

Are you able to connect to your SQL server with a desktop client?

This sounds like it's a server configuration issue; probably something best raised on https://serverfault.com/ or some other dedicated forum to helping with infrastructure issues.

I'm going to close this as I don't think the issue is related to the library

The fix, for anyone interested;
https://github.com/tediousjs/node-mssql/issues/130#issuecomment-75596227

tl;dr - SQL Server Browser is not returning the server's port. Ensure TCP/IP is turned on via Network Configuration and restart both the server and browser instances.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ryankelley picture ryankelley  路  4Comments

cdeutsch picture cdeutsch  路  6Comments

sizovilya picture sizovilya  路  3Comments

andrewmcgivery picture andrewmcgivery  路  5Comments

mhunting picture mhunting  路  6Comments