问题描述
今天启动Nacos的时候莫名其妙的报错了.....
错误信息如下:
其实最重要的就是第一个 error里面提到的:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'grpcSdkServer': Invocation of init method failed; nested exception is java.io.IOException: Failed to bind
解决办法
先说如何解决,目前市面上的Nacos版本主要就是1.4 和 2.0的,本人这里使用的就是2.0版本的。
遇到这种错误的人,我估计都是安装了2.0及其以上的!
查看了Nacos官网,终于知道了原因!简单的来说就是端口被占用了!但是并不是8848,而是由于Nacos2.0版本新增了gRPC通讯方式,而导致自身还需要两个端口 9849 和 9849
官网描述如下:
Nacos 2.0.0 兼容性文档https://nacos.io/zh-cn/docs/2.0.0-compatibility.html所以,如果我们是用的Windows,使用命令查看端口的占用情况,就可以知道是不是上述问题所导致的BUG
Windows的查看端口
netstat -ano | findstr 8848
netstat -ano | findstr 9848
netstat -ano | findstr 9849
Linux的查看端口
netstat -tunlp | grep 8848
netstat -tunlp | grep 9848
netstat -tunlp | grep 9849
查看是什么进程占用
# windows 命令
tasklist | findstr 14548
# 如果是Linux部署请使用下面这个命令
ps -ef | grep 14548
杀掉进程
# windows 命令
taskkill /F /PID 14548 /T
# Linux 命令
kill -9 [pid]
然后重新启动Nacos就可以了!!!
登入Nacos后台管理