title: Exception in thread "main" org.apache.zookeeper.KeeperException$ConnectionLossException: KeeperErrorCode = ConnectionLoss for
body: <p>I am trying a simple zookeeper example for <code>Leader</code> election, and I always get an error and the server doesn't start up. This is my code: </p>
  
  <pre><code>public LeaderElection() throws IOException, InterruptedException, KeeperException {
      setZk(new ZooKeeper("localhost", TIMEOUT, this));
  
      /* This call gives the problem */
      Stat s = getZk().exists(MASTER, this);
  
      if (s == null) {
          getZk().create(MASTER, "This node is used for election.".getBytes(),
                  ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
      }
      //wait till SyncConnected Signal is received in process method.
      latch.await();
  
      setNodePath(getZk().create(MASTER + NODE, null /*no data yet*/,
              ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.EPHEMERAL_SEQUENTIAL));
  }
  </code></pre>
  
  <p>At the <code>exists()</code> call I get the error:  </p>
  
  <blockquote>
    <p>Exception in thread "main" org.apache.zookeeper.KeeperException$ConnectionLossException: KeeperErrorCode = ConnectionLoss for </p>
  </blockquote>
  
  <p>Please let me know what am I missing. I am using version 3.4.5 of zk, and a time out of 15K.</p>