title: Hazelcast: connecting to remote cluster
body: <p>We have a cluster of Hazelcast nodes all running on one remote system (single physical system with many nodes). We would like to connect to this cluster from an external client - a Java application which uses code as below to connect to Hazelcast:</p>
  
  <pre><code>        ClientConfig clientConfig = new ClientConfig();
          clientConfig.addAddress(config.getHost() + ":" + config.getPort());
  
          client = HazelcastClient.newHazelcastClient(clientConfig);
  </code></pre>
  
  <p>where, host is the IP of remote and port is 5701.</p>
  
  <p>This still connects to the local host (127.0.0.1). What am I missing?</p>
  
  <p><strong>Edit:</strong></p>
  
  <p>If the java client is the only hazelcast app running on the local system, it fails to connect and throws the exception: <code>java.lang.IllegalStateException: Cannot get initial partitions!</code></p>
  
  <p>From the logs:</p>
  
  <blockquote>
    <p>14:58:26.717 [main] INFO  c.m.b.p.s.s.HazelcastCacheClient - creating
    new Hazelcast instance</p>
    
    <p>14:58:26.748 [main] INFO  com.hazelcast.core.LifecycleService -
    HazelcastClient[hz.client_0_dev][3.2.1] is STARTING</p>
    
    <p>14:58:27.029 [main] INFO  com.hazelcast.core.LifecycleService -
    HazelcastClient[hz.client_0_dev][3.2.1] is STARTED</p>
    
    <p>14:58:27.061 [hz.client_0_dev.cluster-listener] INFO 
    com.hazelcast.core.LifecycleService -
    HazelcastClient[hz.client_0_dev][3.2.1] is CLIENT_CONNECTED</p>
    
    <p>14:58:27.061 [hz.client_0_dev.cluster-listener] INFO 
    c.h.client.spi.ClientClusterService - </p>
    
    <p>Members [5] {     Member [127.0.0.1]:5701     Member [127.0.0.1]:5702
      Member [127.0.0.1]:5703     Member [127.0.0.1]:5704     Member
    [127.0.0.1]:5705 }</p>
    
    <p>14:58:47.278 [main] ERROR c.h.c.spi.ClientPartitionService - Error
    while fetching cluster partition table!</p>
    
    <p>com.hazelcast.spi.exception.RetryableIOException:
    java.util.concurrent.ExecutionException:
    com.hazelcast.core.HazelcastException: java.net.ConnectException:
    Connection refused: no further information ... Caused by:
    java.util.concurrent.ExecutionException:
    com.hazelcast.core.HazelcastException: java.net.ConnectException:
    Connection refused: no further information</p>
    
    <p>at java.util.concurrent.FutureTask.report(Unknown Source)
    ~[na:1.8.0_31]</p>
    
    <p>at java.util.concurrent.FutureTask.get(Unknown Source) ~[na:1.8.0_31]</p>
    
    <p>at
    com.hazelcast.client.connection.nio.ClientConnectionManagerImpl.getOrConnect(ClientConnectionManagerImpl.java:282)
    ~[BRBASE-service-manager-1.0.0-jar-with-dependencies.jar:na]</p>
    
    <p>... 14 common frames omitted</p>
    
    <p>Caused by: com.hazelcast.core.HazelcastException:
    java.net.ConnectException: Connection refused: no further information</p>
    
    <p>at com.hazelcast.util.ExceptionUtil.rethrow(ExceptionUtil.java:45)
    ~[BRBASE-service-manager-1.0.0-jar-with-dependencies.jar:na] ...</p>
  </blockquote>