Connection Error: Failed to connect to xxxx:xxxx - Socket Hang Up
Hello, I am using the node-mssql package in my nodejs web service. It is required to connect to the MSSQL server located on a remote server and perform user authentication. There is no problem when working with Windows. Everything is working properly. When I work with Linux alone, I get a socket hang up error. I tried to install the necessary tools for SQL Server and run a query with sqlcmd, but I got an error. Then I was able to connect by changing openssl version (1.1.1f -> 1.1.1h). I thought the problem was fixed, I saw that I kept getting the hang up error when I ran the service. When I looked at the past issues, I saw that they usually got a socket hang up error at the time of "connection lost". It was resolved with a version upgrade. The problem here was ConnectionError, which led me to the idea that there was another problem. Any ideas on this?
Thanks a lot!
Incoming error:

Config:
var config = {
user: 'xxxx',
password: 'xxxx',
server: 'xx.xx.xxx.xx',
database: 'xxx',
trustServerCertificate: true,
requestTimeout: 15000,
stream: true,
pool: {
max: 10,
min: 0,
idleTimeoutMillis: 30000,
},
options: {
keepAlive: true,
encrypt: true,
enableArithAbort: true,
},
};
module.exports = config;
Software versions
- NodeJS: 17.3.1
- node-mssql: V7
- SQL Server: 2017
Hello, I am using the node-mssql package in my nodejs web service. It is required to connect to the MSSQL server located on a remote server and perform user authentication. There is no problem when working with Windows. Everything is working properly. When I work with Linux alone, I get a socket hang up error. I tried to install the necessary tools for SQL Server and run a query with sqlcmd, but I got an error. Then I was able to connect by changing openssl version (1.1.1f -> 1.1.1h). I thought the problem was fixed, I saw that I kept getting the hang up error when I ran the service. When I looked at the past issues, I saw that they usually got a socket hang up error at the time of "connection lost". It was resolved with a version upgrade. The problem here was ConnectionError, which led me to the idea that there was another problem. Any ideas on this?
Thanks a lot!
Incoming error:
Config:
var config = { user: 'xxxx', password: 'xxxx', server: 'xx.xx.xxx.xx', database: 'xxx', trustServerCertificate: true, requestTimeout: 15000, stream: true, pool: { max: 10, min: 0, idleTimeoutMillis: 30000, }, options: { keepAlive: true, encrypt: true, enableArithAbort: true, }, }; module.exports = config;Software versions
- NodeJS: 17.3.1
- node-mssql: V7
- SQL Server: 2017
you can try
"options": { "encrypt": false }
@1365436742 Thanks a lot bro! From what I understand from his answer, this is how we got him to connect without encryption because there was a conflict in the communication encryption. Did I think right?
Thank you again. 💯 🚀
encrypt: true is generally for Azure SQL
Glad you got it sorted