Client port found: 2181. Client address: localhost. Client SSL: false.
- 问题:
Client port found: 2181. Client address: localhost. Client SSL: false.
🧩 问题说明
Client address: localhost 表示 ZooKeeper 当前的客户端监听地址是 本机回环地址 127.0.0.1。
这意味着:
-
只有本机能连上 ZooKeeper;
-
外部主机(比如你用 PrettyZoo 的电脑)都无法访问 2181 端口;
-
所以才会出现:
无法打开到主机的连接。在端口 2181: 连接失败
✅ 解决方法
只需要修改 ZooKeeper 的配置文件,允许外部访问即可。
1️⃣ 打开配置文件
vim /opt/apache-zookeeper-3.8.4-bin/conf/zoo.cfg
找到或添加以下两行:
clientPort=2181
clientPortAddress=0.0.0.0
⚠️ 如果文件中已经有:
clientPortAddress=localhost
请将其改为:
clientPortAddress=0.0.0.0
2️⃣ 保存并退出
在 vim 中:
:wq
3️⃣ 重启 ZooKeeper
./zkServer.sh restart

等待几秒钟后执行:
./zkServer.sh status
- 看到输出:

✅ 这说明 ZooKeeper 现在已经监听所有网卡(包括公网 IP)了。
4️⃣ 再次测试连接
在本地电脑上执行:
telnet xx.xx.xx.xx 2181
如果出现空白界面(光标闪烁),说明连接成功。
这时重新打开 PrettyZoo,输入:
xx.xx.xx.xx:2181

连接就能正常建立 🎉
🧠 注意
如果是云服务器(如阿里云 / 腾讯云等),开启如下:
- 安全组规则放行 TCP 2181;

-
Linux 防火墙允许外部访问:
sudo firewall-cmd --add-port=2181/tcp --permanent sudo firewall-cmd --reload
