node.js 程序出现 Error: connect ECONNREFUSED 和 getaddrinfo ENOTFOUND 。
ENOTFOUND 官方定义 : (DNS lookup failed): Indicates a DNS failure of either EAI_NODATA or EAI_NONAME. This is not a standard POSIX error.
这个问题一般是DNS 查询失败导致的。
ECONNREFUSED: (Connection refused): No connection could be made because the target machine actively refused it. This usually results from trying to connect to a service that is inactive on the foreign host.
无法建立连接,因为目标计算机主动拒绝了该连接。 这通常是由于尝试连接到外部主机上处于非活动状态的服务而导致的。 (这个也可能是DNS解析的 IP地址不对,导致远程主机无法连接)
详细日志如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
2020-04-2111:26:19 [PicGoERROR] RequestError: Error: connect ECONNREFUSED13.250.168.23:443 ------ErrorStackBegin------ RequestError: Error: connect ECONNREFUSED13.250.168.23:443 at newRequestError (/Applications/PicGo.app/Contents/Resources/app.asar/node_modules/request-promise-core/lib/errors.js:14:15) at Request.plumbing.callback (/Applications/PicGo.app/Contents/Resources/app.asar/node_modules/request-promise-core/lib/plumbing.js:87:29) at Request.RP$callback [as _callback] (/Applications/PicGo.app/Contents/Resources/app.asar/node_modules/request-promise-core/lib/plumbing.js:46:31) at self.callback (/Applications/PicGo.app/Contents/Resources/app.asar/node_modules/request/request.js:185:22) at Request.emit (events.js:182:13) at Request.onRequestError (/Applications/PicGo.app/Contents/Resources/app.asar/node_modules/request/request.js:881:8) at ClientRequest.emit (events.js:182:13) at TLSSocket.socketErrorListener (_http_client.js:391:9) at TLSSocket.emit (events.js:182:13) at emitErrorNT (internal/streams/destroy.js:82:8) -------ErrorStackEnd-------
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
2020-05-1818:34:22 [PicGoWARN] failed 2020-05-1818:34:22 [PicGoERROR] RequestError: Error: getaddrinfo ENOTFOUND api.github.com ------ErrorStackBegin------ RequestError: Error: getaddrinfo ENOTFOUND api.github.com at newRequestError (/Applications/PicGo.app/Contents/Resources/app.asar/node_modules/request-promise-core/lib/errors.js:14:15) at Request.plumbing.callback (/Applications/PicGo.app/Contents/Resources/app.asar/node_modules/request-promise-core/lib/plumbing.js:87:29) at Request.RP$callback [as _callback] (/Applications/PicGo.app/Contents/Resources/app.asar/node_modules/request-promise-core/lib/plumbing.js:46:31) at self.callback (/Applications/PicGo.app/Contents/Resources/app.asar/node_modules/request/request.js:185:22) at Request.emit (events.js:200:13) at Request.onRequestError (/Applications/PicGo.app/Contents/Resources/app.asar/node_modules/request/request.js:881:8) at ClientRequest.emit (events.js:200:13) at TLSSocket.socketErrorListener (_http_client.js:402:9) at TLSSocket.emit (events.js:200:13) at emitErrorNT (internal/streams/destroy.js:91:8) -------ErrorStackEnd-------