Hello, I am using virtualbox and unable to connect zookeeper from local system to virtual box and here is the error.
2016-07-22 18:35:47,890 WARN zookeeper.RecoverableZooKeeper - Possibly transient ZooKeeper, quorum=127.0.0.1:2181, exception=org.apache.zookeeper.KeeperException$ConnectionLossException: KeeperErrorCode = ConnectionLoss for /hbase-unsecure/hbaseid
2016-07-22 18:35:49,890 WARN zookeeper.ClientCnxn - Session 0x0 for server null, unexpected error, closing socket connection and attempting reconnect java.net.ConnectException: Connection refused: no further information at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method) at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:717) at org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:350) at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1068)
You need to add a forwarding rule on your sandbox VM. While in Oracle VM VirtualBox Manager, right-click on the sandbox and select Settings then go to Network, click on Port Forwarding and add a rule let's call it Zookeeper with Protocol TCP, HostIP 127.0.0.1, HostPort 2181, GuestPort 2181 (or a port that is available, in case 2181 is not), click OK, OK. I don't think you have to restart the VM, even the VM is running, it should work.
If this response addressed your issue, please vote and accept it as the best answer.