Wednesday, August 30, 2017

Node.js MSSQL ConnectionError: Failed to connect to localhost:1433 - connect ECONNREFUSED

Today I was trying Node.js to connect to SQL Server, the connection to the sql server failed with the below error.

name: 'ConnectionError',

  message: 'Failed to conncet to localhost

Below are the steps I have followed to resolve this. Step 1 Ensure that the TCP/IP protocol is Enabled as shown below



Step 2

Ensure that the sql server browser is running as shown below.










Step 3

Node.js connections only supports authenticating with SQL Server accounts.

This is not that clear in the documentation.  It took me a while to figure this.

To ensure that the SQL SERVER is configured for sql server authentication do the following
·       In SQL Server Management Studio Object Explorer, right-click the server, and then click Properties.
·      On the Security page, under Server authentication, select the new server authentication mode, and then click OK.


You might be prompted to restart the sql server. Right click the sql server and restart.  The SQL Server Agent should also be restarted.


 

No comments:

SQL Saturday Auckland 2018 Presentation

On 1st September 2018, I had a wonderful opportunity presenting at the SQL Saturday Auckland event at UNITEC. The title of my session was G...