title: "java.net.ConnectException: Connection refused" in zookeeper
body: <p>I installed zookeeper as follows : </p>
  
  <pre><code>wget http://archive.cloudera.com/cdh/3/zookeeper-3.3.3-cdh3u1.tar.gz
  </code></pre>
  
  <p>Here is my <code>zoo.cf</code>:</p>
  
  <pre><code># The number of milliseconds of each tick
  tickTime=2000
  # The number of ticks that the initial
  # synchronization phase can take
  initLimit=10
  # The number of ticks that can pass between
  # sending a request and getting an acknowledgement
  syncLimit=5
  # the directory where the snapshot is stored.
  dataDir=/home/reach121/basf/data/zookeeper/data1
  # maximum client connection
  maxClientCnxns=500
  # the port at which the clients will connect
  clientPort=2183
  server.1=localhost:2878:3878
  server.2=localhost:2879:3879
  server.3=localhost:2880:3880
  </code></pre>
  
  <p>and started by </p>
  
  <pre><code>/bin/zkServer.sh start zoo.cfg
  </code></pre>
  
  <p>and when I do? </p>
  
  <pre><code>bin/zkCli.sh -server 127.0.0.1:2183
  </code></pre>
  
  <p>it gives me this error: </p>
  
  <pre><code>Connecting to 127.0.0.1:2183
  2011-10-13 14:11:28,433 - INFO  [main:Environment@97] - Client environment:zookeeper.version=3.3.3-cdh3u1--1, built on 07/18/2011 15:17 GMT
  2011-10-13 14:11:28,437 - INFO  [main:Environment@97] - Client environment:host.name=cignexnew
  2011-10-13 14:11:28,437 - INFO  [main:Environment@97] - Client environment:java.version=1.6.0_22
  2011-10-13 14:11:28,438 - INFO  [main:Environment@97] - Client environment:java.vendor=Sun Microsystems Inc.
  2011-10-13 14:11:28,438 - INFO  [main:Environment@97] - Client environment:java.home=/usr/lib/jvm/java-6-openjdk/jre
  2011-10-13 14:11:28,439 - INFO  [main:Environment@97] - Client environment:java.class.path=/home/reach121/basf/zookeeper-3.3.3-cdh3u1/bin/../build/classes:/home/reach121/basf/zookeeper-3.3.3-cdh3u1/bin/../build/lib/*.jar:/home/reach121/basf/zookeeper-3.3.3-cdh3u1/bin/../zookeeper-3.3.3-cdh3u1.jar:/home/reach121/basf/zookeeper-3.3.3-cdh3u1/bin/../lib/log4j-1.2.15.jar:/home/reach121/basf/zookeeper-3.3.3-cdh3u1/bin/../lib/jline-0.9.94.jar:/home/reach121/basf/zookeeper-3.3.3-cdh3u1/bin/../src/java/lib/*.jar:/home/reach121/basf/zookeeper-3.3.3-cdh3u1/bin/../conf:
  2011-10-13 14:11:28,439 - INFO  [main:Environment@97] - Client environment:java.library.path=/usr/lib/jvm/java-6-openjdk/jre/lib/amd64/server:/usr/lib/jvm/java-6-openjdk/jre/lib/amd64:/usr/lib/jvm/java-6-openjdk/jre/../lib/amd64:/usr/java/packages/lib/amd64:/usr/lib/x86_64-linux-gnu/jni:/lib/x86_64-linux-gnu:/usr/lib/x86_64-linux-gnu:/usr/lib/jni:/lib:/usr/lib
  2011-10-13 14:11:28,440 - INFO  [main:Environment@97] - Client environment:java.io.tmpdir=/tmp
  2011-10-13 14:11:28,440 - INFO  [main:Environment@97] - Client environment:java.compiler=&lt;NA&gt;
  2011-10-13 14:11:28,441 - INFO  [main:Environment@97] - Client environment:os.name=Linux
  2011-10-13 14:11:28,441 - INFO  [main:Environment@97] - Client environment:os.arch=amd64
  2011-10-13 14:11:28,441 - INFO  [main:Environment@97] - Client environment:os.version=2.6.35.4-rscloud
  2011-10-13 14:11:28,442 - INFO  [main:Environment@97] - Client environment:user.name=reach121
  2011-10-13 14:11:28,443 - INFO  [main:Environment@97] - Client environment:user.home=/home/reach121
  2011-10-13 14:11:28,443 - INFO  [main:Environment@97] - Client environment:user.dir=/home/reach121/basf/zookeeper-3.3.3-cdh3u1
  2011-10-13 14:11:28,446 - INFO  [main:ZooKeeper@373] - Initiating client connection, connectString=127.0.0.1:2183 sessionTimeout=30000 watcher=org.apache.zookeeper.ZooKeeperMain$MyWatcher@5311a775
  Welcome to ZooKeeper!
  2011-10-13 14:11:28,472 - INFO  [main-SendThread():ClientCnxn$SendThread@1041] - Opening socket connection to server /127.0.0.1:2183
  JLine support is enabled
  2011-10-13 14:11:28,487 - WARN  [main-SendThread(localhost:2183):ClientCnxn$SendThread@1161] - Session 0x0 for server null, unexpected error, closing socket connection and attempting reconnect
  java.net.ConnectException: Connection refused
          at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
          at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:592)
          at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1119)
  [zk: 127.0.0.1:2183(CONNECTING) 0] 2011-10-13 14:11:30,374 - INFO  [main-SendThread(localhost:2183):ClientCnxn$SendThread@1041] - Opening socket connection to server localhost/127.0.0.1:2183
  2011-10-13 14:11:30,376 - WARN  [main-SendThread(localhost:2183):ClientCnxn$SendThread@1161] - Session 0x0 for server null, unexpected error, closing socket connection and attempting reconnect
  java.net.ConnectException: Connection refused
          at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
          at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:592)
          at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1119)
  </code></pre>