I'm trying to connect to a Microsoft SQL Server using Knex.js, but I'm getting getaddrinfo ENOTFOUND. I'm aware that this is an indication, that NodeJS is unable to resolve the address, often through DNS or protocol problems.
const knex = require('knex')({
client: 'mssql',
connection: {
server: 'filesrv\\docx', // backslash in string needs to be escaped
user: 'user', // changed for privacy reasons
password: 'secret', // changed for privacy reasons
options: {
port: 1433,
database: 'DX_Matching_DB'
}
}
});
UnhandledPromiseRejectionWarning: ConnectionError: Failed to connect to filesrv\docx:1433 - getaddrinfo ENOTFOUND filesrv\docx
at ConnectionError(.\node_modules\tedious\lib\errors.js:13:12)
at Connection.socketError(.\node_modules\tedious \lib\connection.js:1664:56)
...
SQL Server in SQL Server Object Explorer:
App is run on Windows. Resolve-DnsName is able to resolve filesrv\docx. No change when exchanging filesrv for the corresponding IP.
2条答案
按热度按时间qcuzuvrc1#
The knex configuration object uses the instance name inside the options, e.g.:
tf7tbtn22#
You have to setting port in Sql Server Configuration Manager - SQL Server Network Configuration -> TCP/IP -> Properties -> IP Address -> Set IP 4 or 6 (example: 1466)
Restart Sql Server enter code here