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.


 

2 comments:

Umamaheswararao Meka said...

Thank you, this worked for me !!!

sir_music said...

Thank you so much! I'm a little closer to figuring out what is the issue in my own system as now at least I'm getting a `ConnectionError: Login failed for user 'DevAdmin'` result :-)

Free Power BI Classes for Week 7 (Last)

Just completed the last class of the F ree  P ower BI  classes of this series.  Today we have covered Adding a canvas background Adding Imag...