tediousjs / tedious

Node TDS module for connecting to SQL Server databases.

Home Page:http://tediousjs.github.io/tedious/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error creating connection pool. ConnectionError: Failed to connect to localhost:[port] - connect ECONNREFUSED [ip][port]

Julia1205 opened this issue · comments

Hello,

I'm having troubles to connect a node.js app to SQL Server. I don't know why the connection is refused since the user on SQL server have, I think, all the authorizations for the app.

Here is the error :

Error creating connection pool. ConnectionError: Failed to connect to localhost:[port] - connect ECONNREFUSED 127.0.0.1:[port]
at Connection. (C:\Users[...]\node_modules\mssql\lib\tedious.js:378:25)
at Object.onceWrapper (node:events:628:26)
at Connection.emit (node:events:513:28)
at Connection.socketError (C:\Users[...]\node_modules\mssql\node_modules\tedious\lib\connection.js:531:14)
at Socket.emit (node:events:513:28)
at emitErrorNT (node:internal/streams/destroy:151:8)
at emitErrorCloseNT (node:internal/streams/destroy:116:3)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
code: 'ESOCKET'

Can someone help me with this please ?
Thanks alot

Hi @Julia1205, Can you provide your connection configuration, so we have a bit more information to help you investigate this? I also did a quick search, people mentioned this could be caused by something else is actively running on the localhost:[port] that you are trying to connect to, which cause the ECONNREFUSED error.
By the way, have you try to connect to you server via SQL server management studio(SSMS)?

Hi @MichaelSun90, the database is on local and so is the app. The port is 1433 for the database. There is no app already running on this port. If I try to connect on SSMS with the user I created for the app, I have a 233 error but with windows authentication I have access to the database.
I don't have much knowledge about servers or network, which informations do you need ?
Sorry for my english and thanks for your help !

Hi @Julia1205, based on you getting a 233 error (Microsoft doc explaining what that is here), it may be that your database is not configured to accept remote connections. You can follow these steps here: Configure the remote access Server Configuration Option

If that doesn't work, please confirm that your user has the correct permissions to connect to the DB.

Please provide the following info so we can help you further:

Software versions

  • Tedious:
  • SQL Server:
  • Node.js:

Connection configuration:

Additional Libraries Used and Versions if applicable (e.g. node-mssql, sequelize, etc.):