title: Connection refused to host exception in java RMI
body: <p>When I tried to communicate with server using RMI the following exception occurred  </p>
  
  <pre><code>Exception in thread "main" java.rmi.ConnectException: Connection refused to host : 172.16.7.229; nested exception is:
       java.net.ConnectException: Connection timed out: connect
       at sun.rmi.transport.tcp.TCPEndpoint.newSocket(Unknown Source)
       at sun.rmi.transport.tcp.TCPChannel.createConnection(Unknown Source)
       at sun.rmi.transport.tcp.TCPChannel.newConnection(Unknown Source)
       at sun.rmi.server.UnicastRef.invoke(Unknown Source)
       at SI_Stub.add(Unknown Source)
       at RC.main(RC.java:15) Caused by: java.net.ConnectException: Connection timed out: connect
       at java.net.DualStackPlainSocketImpl.connect0(Native Method)
       at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
       at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
       at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
       at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
       at java.net.PlainSocketImpl.connect(Unknown Source)
       at java.net.SocksSocketImpl.connect(Unknown Source)
       at java.net.Socket.connect(Unknown Source)
       at java.net.Socket.connect(Unknown Source)
       at java.net.Socket.&lt;init&gt;(Unknown Source)
       at java.net.Socket.&lt;init&gt;(Unknown Source)
       at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(Unknown Source)
       at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(Unknown Source)
       ... 6 more
  </code></pre>
  
  <p>Note: I am not using port, I have already started the rmiregistry. </p>