eureka报错:链接8761被拒绝
来龙去脉
在idea环境中运行没有问题
我的配置是:
server:
port: 8001
spring:
application:
name: registry-server
eureka:
instance:
hostname: localhost
client:
fetch-registry: false
register-with-eureka: false
微服务部署后,eureka服务会不断报上面的错误
org.apache.http.conn.HttpHostConnectException: Connect to localhost:8761 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: 拒绝连接
连接http://localhost:8761/eureka 的注册中心被拒绝,无法连接
可是我已经改了端口为8001
即时只启动eureka服务仍然报错,但是报错又不影响客户端的注册和发现
部署后的配置:
server:
port: 8001
spring:
application:
name: eureka-server
eureka:
instance:
hostname: 192.168.110.157
client:
fetch-registry: false
register-with-eureka: false
原因分析
8761 是Eureka的默认路径, Eureka认为启动配置里没有对它的url地址指定时, 会默认寻找这个地址
解决办法
用defaultZone配置注册中心地址
server:
port: 8001
spring:
application:
name: eureka-server
eureka:
instance:
hostname: 192.168.110.157
client:
fetch-registry: false
register-with-eureka: false
service-url:
defaultZone: http://localhost:8001/eureka/
版权归原作者 Kwoky 所有, 如有侵权,请联系我们删除。