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

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


The solution is to enable TCP connections which are disabled by default.

enter image description here


My case wasn't exactly the same as Matt's, but his screenshot was enough to remember me what was missing.

enter image description here

As it is said here, when you are using the SQL Server Instance Name to connect to it, you must have SQL Server Browser running.

options.instanceName

The instance name to connect to. The SQL ServerBrowser service must be running on the database server, and UDP port1434 on the database server must be reachable.

(no default)

Mutually exclusive with options.port.


If after enabling the TCP connection and your configuration is still not working. Here's my own-configuration.

var config = {    "user": 'admin',    "password": 'password',    "server": 'WINDOWS-PC',    "database": 'database_name',    "port": 61427, // make sure to change port    "dialect": "mssql",    "dialectOptions": {        "instanceName": "SQLEXPRESS"    }};