拨打 tcp 127.0.0.1:8500: getsockopt: 领事拒绝连接

Dial tcp 127.0.0.1:8500: getsockopt: connection refused in consul

我在 consul 服务器和客户端上 运行ning 任何 "consul members" 时收到此错误。该端口处于 LISTENING 状态,我确保没有防火墙阻止。我在 运行 中收到此错误,与领事客户端中的相同:

Error retrieving members: Get http://127.0.0.1:8500/v1/agent/members:
dial tcp 127.0.0.1:8500: connectex: No connection could be made because the target machine actively refused it.

当我使用私有 IP 发出上述请求时,我得到了所需的输出。我可以在任何地方更改配置,以便它在私有 IP 上侦听请求吗?

您的 consul members 似乎缺少选项 -http-addr=...

例子

consul members -http-addr=10.10.10.10:8500

同时假设您使用领事代理的标准端口 8500 并且您通过以下方式启动领事:

consul agent -client=10.10.10.10 #...

在哪里可以找到文档?

  • Running an Agent: "Client Addr" 下的 Consul 文档中:

    If you change this address or port, you'll have to specify a -http-addr whenever you run commands such as consul members to indicate how to reach the agent.

  • 或离线通过consul members -help:

    http-addr=<address> Theaddressand port of the Consul HTTP agent. The value can be an IP address or DNS address, but it must also include the port. This can also be specified via the CONSUL_HTTP_ADDR environment variable. The default value is http://127.0.0.1:8500. The scheme can also be set to HTTPS by setting the environment variable CONSUL_HTTP_SSL=true.