Trouble connecting to SQL Server Express with Node.js
<p>I am currently trying to establish a connection to a SQL Server instance on my local machine with the following Node program, <code>app.js</code>:</p>

<pre><code>var sql = require('mssql');

sql.connect("mssql://sa:temp2@localhost/Northwind").then(function() {
    // Query 

    new sql.Request().query('select * from TableName').then(function(recordset) {
        console.dir(recordset);
    }).catch(function(err) {
        console.log(err);
    });

}).catch(function(err) {
    console.log(err);
});
</code></pre>

<p>And the error: </p>

<blockquote>
  <p>{ ConnectionError: Failed to connect to localhost:1433 - connect
  ECONNREFUSED 127.0.0.1:1433</p>
  
  <p>at Connection.
  (C:\Users\name\nodeprac\node_modules\mssql\lib\tedious.js:378:25)</p>
  
  <p>at Connection.g (events.js:286:16)</p>
  
  <p>at emitOne (events.js:96:13)</p>
  
  <p>at Connection.emit (events.js:188:7)</p>
  
  <p>at Connection.socketError
  (C:\Users\name\nodeprac\node_modules\tedious\lib\connection.js:531:14)</p>
  
  <p>at emitOne (events.js:96:13)</p>
  
  <p>at Socket.emit (events.js:188:7)</p>
  
  <p>at emitErrorNT (net.js:1272:8)</p>
  
  <p>at _combinedTickCallback (internal/process/next_tick.js:74:11)</p>
  
  <p>at process._tickCallback (internal/process/next_tick.js:98:9)</p>
  
  <p>name: 'ConnectionError',</p>
  
  <p>message: 'Failed to connect to localhost:1433 - connect ECONNREFUSED
  127.0.0.1:1433',</p>
  
  <p>code: 'ESOCKET' }</p>
</blockquote>

<p>I've tried a million other ways of establishing a connection with other errors, but I feel like there must be something simple here that I am missing. Also, there is more than one instance of SQLServer Express on my machine. Would removing one help? I've enabled all <code>TCP/IP</code> ports for the current server, and set all ports to <code>1433</code></p>

<p>Any advice would be very much appreciated.</p>