title: Problems in connecting with SQL Server using node js?
body: <p>I am trying to connect to a remote sql server database which is hosted in a remote server using node js. Now, I tried to connect to the same database using c# and everything works perfect but I tried the same thing with Node and I keep getting error logs. I am unable to understand if the problem is at my end or is it the problem with the server.</p>
  
  <pre><code>var sql = require('mssql');
  
  var config = {
      userName: 'realm',
      password: 'friend',
      server: '172.10.3.22',
  
      options: {
  
          database: 'ElmaTest',
          instancename: 'SQL2014'
      }
  };
  
  
  
  
  var updateMember = function( username, password) {
      return sql.execute( {
          procedure: "updateMember",
          params: {
  
              firstName: {
                  type: sql.NVARCHAR,
                  val: username
              },
              lastName: {
                  type: sql.NVARCHAR,
                  val: password
              }
          }
      } );
  };
  
  function  connecttoDb() {
  
    //  updateMember("elma","pass1234");
      sql.connect(config, function (err) {
  
          if (err) console.log("message" + err);
  
  
      });
  
  
  }
  
  module.exports.datavalue = connecttoDb();
  </code></pre>
  
  <p>Error logs:- 
  Example app listening at <a href="http://:::8081" rel="nofollow noreferrer">http://:::8081</a>
  messageConnectionError: Failed to connect to 172.10.3.22:1433 - connect ECONNREF
  USED 172.10.3.22:1433</p>
  
  <p>The thing is that the same connection string works with c# but refuses to work with Node js.</p>
  
  <p>C# connection string:</p>
  
  <pre><code>&lt;add name="ElmaReport" connectionString="Data Source=172.10.3.22\SQL2014;Initial Catalog=ElmaTest;User ID=realm;password=friend" providerName="System.Data.SqlClient" /&gt;
  </code></pre>