Timeout connecting to [localhost/127.0.0.1:9200]


空服务启动时(或者压根没引入es相关jar包)报Timeout connecting to [localhost/127.0.0.1:9200]错误时,查看pom.xml中是否引用了


    org.springframework.boot
    spring-boot-starter-actuator

该组件是sprongboot核心组件之一,里面默认集成了es,会进行es健康检查

1.取消对es健康检查在management:标签中添加

management:
  health:
    elasticsearch:
      enabled: false

2.配置自己可以正常连接的es地址,去替换默认127.0.0.1:9200地址

spring.elasticsearch.rest.uris=["xxxx:9200"]