ruoyi-cloud docker启动微服务无法连接nacos,Client not connected, current status:STARTING
ruoyi-cloud docker启动微服务无法连接nacos,Client not connected, current status:STARTING
场景
当使用sh deploy.sh base
来安装mysql、redis、nacos环境后,紧接着使用sh deploy.sh modules
安装微服务模块,会发现微服务无法连接nacos的情况,报错为
Caused by: com.alibaba.nacos.api.exception.NacosException: Client not connected, current status:STARTING
2025-01-14 19:47:24 at com.alibaba.nacos.common.remote.client.RpcClient.request(RpcClient.java:639)
2025-01-14 19:47:24 at com.alibaba.nacos.common.remote.client.RpcClient.request(RpcClient.java:619)
2025-01-14 19:47:24 at com.alibaba.nacos.client.naming.remote.gprc.NamingGrpcClientProxy.requestToServer(NamingGrpcClientProxy.java:356)
2025-01-14 19:47:24 at com.alibaba.nacos.client.naming.remote.gprc.NamingGrpcClientProxy.doRegisterService(NamingGrpcClientProxy.java:209)
2025-01-14 19:47:24 at com.alibaba.nacos.client.naming.remote.gprc.NamingGrpcClientProxy.registerService(NamingGrpcClientProxy.java:123)
2025-01-14 19:47:24 at com.alibaba.nacos.client.naming.remote.NamingClientProxyDelegate.registerService(NamingClientProxyDelegate.java:98)
2025-01-14 19:47:24 at com.alibaba.nacos.client.naming.NacosNamingService.registerInstance(NacosNamingService.java:152)
2025-01-14 19:47:24 at com.alibaba.cloud.nacos.registry.NacosServiceRegistry.register(NacosServiceRegistry.java:75)
2025-01-14 19:47:24 ... 35 common frames omitted
分析原因
docker compose搭建的docker容器中,一个容器不应该使用localhost来访问另一个容器,例如在微服务模块中配置
# 服务注册地址
server-addr: 127.0.0.1:8848
这样在容器中是无法访问到nacos的
应该改为:
# 服务注册地址
server-addr: ruoyi-nacos:8848
对应所有位置都需要修改
修改后微服务容器成功启动