0

I changed the default port 1433 on my SQL Server in centos 7. But in API that is created with Node.js and uses the mssql package to connect to it, I get the error shown here when I want to send or get a request. mssql knows 1433 port as default.

My connection string

var sql = require('mssql');

var DbConnectionString = {
        user: 'sa',
        password: 'mypassword',
        server: 'serverip,newport',
        database: 'databasename',
    "options": {
    "encrypt": false,
    "enableArithAbort": true
    },    
};

module.exports = DbConnectionString;

And this is the error I get:

{
    "code": "ESOCKET",
    "originalError": {
        "message": "Failed to connect to myserverip,mynewport:1433 - getaddrinfo ENOTFOUND myserverip,mynewport",
        "code": "ESOCKET"
    },
    "name": "ConnectionError"
}

How to solve it?

1 Answer 1

1

The mssql docs state that port can be specified with the 'port' key:

var DbConnectionString = {
    user: 'sa',
    password: 'mypassword',
    server: 'serverip',
    port: newport,
    database: 'databasename',
    "options": {
        "encrypt": false,
        "enableArithAbort": true
    },    
};
Sign up to request clarification or add additional context in comments.

1 Comment

I added a small fix (port argument should be an integer). It worked for me.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.