0

I am trying to connect mssql server with node.js using mssql package. (https://www.npmjs.org/package/mssql). And I am getting following error. But my server name not xc-pc, my server name is xc-pc\r2.

is there any problem connect to msseql server named instance (r2)? how can I fix this?

connection to xc-pc 2:1433 - failed Error: getaddrinfo ENOTFOUND

2 Answers 2

3

You should be able to connect to named instance with this config:

var config = {
    user: '...',
    password: '...',
    server: 'xp-pc',
    database: '...',
    options: {
        instanceName: 'r2'
    }
}

You should also try to connect with IP address instead of hostname.

Sign up to request clarification or add additional context in comments.

Comments

1

It appears that you are trying to connect to Azure instance. You will need to remove both tcp and the port from the server name as follow:

var config = {
    user: '...',
    password: '...',
    server: 'something.database.windows.net', // Remove tcp and port from the server name
    database: '...',

    options: {
         encrypt: true // Use this if you're on Windows Azure
    }
};

1 Comment

Great. Where to find info like this?

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.