I am using the following scripts to run Zookeeper and Kafka in MAC M1 machine
Zookeeper:-
docker run --name zookeeper -p 2181:2181 -e ZOOKEEPER_TICK_TIME=2000 -e ZOOKEEPER_INIT_LIMIT=10 -e ZOOKEEPER_SYNC_LIMIT=5 -e ZOOKEEPER_CLIENT_PORT=2181 confluentinc/cp-zookeeper
Kafka:-
docker run --name kafka -p 9092:9092 -e KAFKA_ZOOKEEPER_CONNECT=0.0.0.0:2181 -e KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://0.0.0.0:9092 confluentinc/cp-kafka
Zookeeper is Running successfully, but kafka is unable to connect to zookeeper with the following error
[2022-11-18 21:15:48,461] INFO Opening socket connection to server 0.0.0.0/0.0.0.0:2181. (org.apache.zookeeper.ClientCnxn)
[2022-11-18 21:15:48,462] INFO SASL config status: Will not attempt to authenticate using SASL (unknown error) (org.apache.zookeeper.ClientCnxn)
[2022-11-18 21:15:48,462] WARN Session 0x0 for sever 0.0.0.0/0.0.0.0:2181, Closing socket connection. Attempting reconnect except it is a SessionExpiredException. (org.apache.zookeeper.ClientCnxn)
java.net.ConnectException: Connection refused
at java.base/sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
at java.base/sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:777)
at org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:344)
at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1290)
[2022-11-18 21:15:49,593] INFO Opening socket connection to server 0.0.0.0/0.0.0.0:2181. (org.apache.zookeeper.ClientCnxn)
[2022-11-18 21:15:49,594] INFO SASL config status: Will not attempt to authenticate using SASL (unknown error) (org.apache.zookeeper.ClientCnxn)
[2022-11-18 21:15:49,595] WARN Session 0x0 for sever 0.0.0.0/0.0.0.0:2181, Closing socket connection. Attempting reconnect except it is a SessionExpiredException. (org.apache.zookeeper.ClientCnxn)
java.net.ConnectException: Connection refused
at java.base/sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
at java.base/sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:777)
at org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:344)
at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1290)
[2022-11-18 21:15:50,722] INFO Opening socket connection to server 0.0.0.0/0.0.0.0:2181. (org.apache.zookeeper.ClientCnxn)
[2022-11-18 21:15:50,722] INFO SASL config status: Will not attempt to authenticate using SASL (unknown error) (org.apache.zookeeper.ClientCnxn)
[2022-11-18 21:15:50,723] WARN Session 0x0 for sever 0.0.0.0/0.0.0.0:2181, Closing socket connection. Attempting reconnect except it is a SessionExpiredException. (org.apache.zookeeper.ClientCnxn)
java.net.ConnectException: Connection refused
at java.base/sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
at java.base/sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:777)
at org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:344)
at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1290)
Even when I try to telnet for 0.0.0.0 2181 i get the following error
Trying 0.0.0.0...
Connected to 0.0.0.0.
Escape character is '^]'.
Connection closed by foreign host.
Please let me know what configuration changes needs to be done for a successful connection.