Skip to content
This repository has been archived by the owner on Apr 23, 2019. It is now read-only.

Connection Refuse when ZK_HOST is localhost:2181 #17

Open
MrXu opened this issue Jan 18, 2017 · 4 comments
Open

Connection Refuse when ZK_HOST is localhost:2181 #17

MrXu opened this issue Jan 18, 2017 · 4 comments

Comments

@MrXu
Copy link

MrXu commented Jan 18, 2017

I have Zookeeper and Kafka running in localhost.
When I start the docker container with

docker run -it --rm  -p 9000:9000 -e ZK_HOSTS="localhost:2181" sheepkiller/kafka-manager

it throws error

java.net.ConnectException: Connection refused
	at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method) ~[na:1.8.0_111]
	at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:717) ~[na:1.8.0_111]
	at org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:361) ~[org.apache.zookeeper.zookeeper-3.4.6.jar:3.4.6-1569965]
	at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1081) ~[org.apache.zookeeper.zookeeper-3.4.6.jar:3.4.6-1569965]

Both zookeeper and kafka are running fine and listening to correct ports. What might be the cause?

@MrXu
Copy link
Author

MrXu commented Jan 19, 2017

Answer my own question.
The problem is with Docker not Kafka-manager.
Basically, java.net.ConnectException: Connection refused says either the server is not started or the port is not listening.
The default ZK_HOST is the localhost:2181 inside docker container. However, my zookeeper is running in the docker host machine at localhost:2181.
So, changing the docker run command to the following will enable container to use host's network:
docker run -it --rm --net="host" -p 9000:9000 -e ZK_HOSTS="localhost:2181" sheepkiller/kafka-manager

@brunoripa
Copy link

brunoripa commented May 18, 2017

Interestingly is that if you do what you suggest, Kafka Manager is able to connect to ZooKeeper, but you will not be able to connect to the UI anymore. Or, at least this is what is happening to me. I have three docker containers, one runs km, one kafka and one zookeeper.

Addition: in my specific scenario, the containers were missing a link. So, defined a network used by both and giving a name to containers, it all worked perfectly.

@jdgiotta
Copy link

jdgiotta commented Aug 9, 2017

@brunoripa he is running kafka/zookeeper on the host and not in another container. Your solution is appropriate for a kafka instance running in docker.

@gkohen
Copy link

gkohen commented Mar 14, 2019

@brunoripa can you elaborate how you define a network to make the UI work?
Thanks.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants