[英]Node js - Error getaddrinfo ENOTFOUND
I'm working with node and i'm having this error but this only happens sometimes. 我正在使用节点,但遇到此错误,但这仅在某些时候发生。 But this time is permanent. 但这一次是永久的。
My config: 我的配置:
var mssql = require("mssql");
var config =
{
user: "user",
password: "pass",
server: "devsv",
database: "db"
}
var db = new mssql.Connection(config);
db.connect(function(err)
{
console.log(err);
});
module.exports = db;
Erro: 错误:
{ ConnectionError: Failed to connect to devsv:1433 - getaddrinfo ENOTFOUND devsv devsv:1433
at Connection.<anonymous> (/Users/user/Projects/p1/node_modules/mssql/lib/tedious.js:378:25)
at Object.onceWrapper (events.js:290:19)
at emitOne (events.js:96:13)
at Connection.emit (events.js:188:7)
at Connection.socketError (/Users/user/Projects/p1/node_modules/tedious/lib/connection.js:531:14)
at emitOne (events.js:96:13)
at Socket.emit (events.js:188:7)
at connectErrorNT (net.js:1025:8)
at _combinedTickCallback (internal/process/next_tick.js:74:11)
at process._tickCallback (internal/process/next_tick.js:98:9)
name: 'ConnectionError',
message: 'Failed to connect to devsv:1433 - getaddrinfo ENOTFOUND devsv devsv:1433',
code: 'ESOCKET' }
Thank you. 谢谢。
ENOTFOUND
typically means the hostname could not be resolved to an address. ENOTFOUND
通常表示主机名无法解析为地址。
There are many possible causes, including: 可能的原因有很多,包括:
You may need to add devsv
to your local hostname resolution configuration (eg, add an entry for it to /etc/hosts
). 您可能需要将devsv
添加到本地主机名解析配置中(例如,将其条目添加到/etc/hosts
)。
Maybe your default domain is not set properly on your server. 也许您的服务器上的默认域设置不正确。
Maybe you have a typo in the hostname and it is not supposed to be devsv
but something else. 也许您的主机名中有一个错字,它不应该是devsv
而是其他东西。
The above is not an exhaustive list, but those are likely causes. 以上不是详尽的清单,但可能是原因。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.