为什么会出现此错误:错误:连接ECONNREFUSED?

时间:2020-09-22 13:59:03

标签: javascript node.js api mailchimp

我正在尝试连接到API Mailchimp,但是启动app.js时出现此错误。

import mailchimp from "@mailchimp/mailchimp_marketing";

mailchimp.setConfig({
  apiKey: "apiKey",
  server: "server",
});

async function run() {
  const response = await mailchimp.ping.get();
  console.log(response);
}

run();

这是完整的错误:

(node:27226) UnhandledPromiseRejectionWarning: Error: connect ECONNREFUSED 0.0.0.0:443
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1144:16)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:27226) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:27226) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

1 个答案:

答案 0 :(得分:0)

ECONNREFUSED表示您的操作系统无法建立TCP连接。您自己的计算机0.0.0.0:443上没有监听的服务。您确定0.0.0.0是您需要连接的主机吗?

您需要在计算机上启动所需的服务,或者需要使用正确的IP地址(无论使用哪种地址)。