Get "http://localhost:8006/actuator/health": dial tcp 127.0.0.1:8006: connect: connection refused

为什么拒绝连接呢?
consul注册服务在虚拟机centos8上,
配置文件如下,

server:
  port: 8006

spring:
  application:
    name: consul-provider-payment
  #consul注册中心地址
  cloud:
    consul:
      host: 172.26.158.62
      port: 8500
      discovery:
        service-name: ${spring.application.name}
#        prefer-ip-address: true # 表示注册时使用IP而不是hostname

prefer-ip-address是在网上找到,但还是没能解决问题
没加prefer-ip-address之前,错如下

img

添加prefer-ip-address之后

img

centos8上的端口:

img

你好,我是有问必答小助手,非常抱歉,本次您提出的有问必答问题,技术专家团超时未为您做出解答


本次提问扣除的有问必答次数,将会以问答VIP体验卡(1次有问必答机会、商城购买实体图书享受95折优惠)的形式为您补发到账户。


​​因为有问必答VIP体验卡有效期仅有1天,您在需要使用的时候【私信】联系我,我会为您补发。