title: Not able to connect to SQL database from nodejs
body: <p>So I'm new to node.js and I'm trying to make a connection to my local database to later insert data.
  However when I execute my code it gives me a connection error with errorcode ESOCKET. I tried different ways to structure my connectionstring but it always gives me this error.</p>
  <p>As I said I'm new to nodejs so I'm not really sure if the problem is my connection string or the port it uses (1433) or something entirely different.</p>
  <h3>code:</h3>
  <pre class="lang-js prettyprint-override"><code>const sql = require('mssql');
  const config = {
    user: 'test',
    password: 'test',
    server: '.',
    database: 'Parkings'
  }
  
  async function databaseconn(parking){
     try{
         let pool = await sql.connect(config);
           await pool.request().query(`
            if not exists (select 1 from [Parking] where [Name] = '${parking.name}')
            begin
            insert into Parking ([Name], [Type], [Latitude], [Longtitude], [MaxCap]) 
            values ('${parking._name}', '${parking._type}', ${parking._latitude}, ${parking._longitude}, ${parking._maxcap})
            end
          `);
          await pool.request().query(`
          insert into [Entry] ([TimeDay], [Available], [ParkingId]) 
          values (${p._time}, ${p._available}, (select Id from Parking where Name = '${p._name}'))
          `);
        pool.close();
    } catch (err){
      console.log(err);
    }
  }
  </code></pre>
  <h3>error:</h3>
  <pre class="lang-sh prettyprint-override"><code>ConnectionError: Failed to connect to .:1433 - getaddrinfo ENOTFOUND .
      at Connection.&lt;anonymous&gt; (D:\Documenten\2019-2020\ParkingProject\nodejs_serverapp\node_modules\mssql\lib\tedious\connection-pool.js:68:17)
      at Object.onceWrapper (events.js:428:26)
      at Connection.emit (events.js:321:20)
      at Connection.socketError (D:\Documenten\2019-2020\ParkingProject\nodejs_serverapp\node_modules\tedious\lib\connection.js:1290:12)
      at D:\Documenten\2019-2020\ParkingProject\nodejs_serverapp\node_modules\tedious\lib\connection.js:1116:21
      at GetAddrInfoReqWrap.callback (D:\Documenten\2019-2020\ParkingProject\nodejs_serverapp\node_modules\tedious\lib\connector.js:158:16)
      at GetAddrInfoReqWrap.onlookupall [as oncomplete] (dns.js:76:17) {
    code: 'ESOCKET',
    originalError: ConnectionError: Failed to connect to .:1433 - getaddrinfo ENOTFOUND .
        at ConnectionError (D:\Documenten\2019-2020\ParkingProject\nodejs_serverapp\node_modules\tedious\lib\errors.js:13:12)
        at Connection.socketError (D:\Documenten\2019-2020\ParkingProject\nodejs_serverapp\node_modules\tedious\lib\connection.js:1290:56)
        at D:\Documenten\2019-2020\ParkingProject\nodejs_serverapp\node_modules\tedious\lib\connection.js:1116:21
        at GetAddrInfoReqWrap.callback (D:\Documenten\2019-2020\ParkingProject\nodejs_serverapp\node_modules\tedious\lib\connector.js:158:16)
        at GetAddrInfoReqWrap.onlookupall [as oncomplete] (dns.js:76:17) {
      message: 'Failed to connect to .:1433 - getaddrinfo ENOTFOUND .',
      code: 'ESOCKET'
    },
    name: 'ConnectionError'
  }
  </code></pre>
  <p><a href="https://i.stack.imgur.com/qyx6v.png" rel="nofollow noreferrer">picture</a></p>
  <h1>SOLUTION</h1>
  <p>after a lot of trouble I fount the sollution to the issue thanks to a github post. You have to enable the TCP/IP protocol on your sql server and restart it. Guide in links below:</p>
  <p><a href="https://github.com/tediousjs/tedious/issues/799" rel="nofollow noreferrer">https://github.com/tediousjs/tedious/issues/799</a></p>
  <p><a href="https://www.blackbaud.com/files/support/infinityinstaller/content/installermaster/tkenablenamedpipesandtcpipconnections.htm" rel="nofollow noreferrer">https://www.blackbaud.com/files/support/infinityinstaller/content/installermaster/tkenablenamedpipesandtcpipconnections.htm</a></p>