title: Java RMI binding problems with dns address
body: <p>I'm writing a client-server application which uses RMI. I use dyndns in order to get a immutable address on which I can accept the clients' connections.
  But I have some problem in doing the binding operation in the server because I receive this error:
  <strong>Connection Refused: connect</strong></p>
  
  <p>I do the binding operation in this way:</p>
  
  <pre><code>MultiServer multi = new MultiServer(); // creates an instance of the remote object
  LocateRegistry.createRegistry(port);
  Naming.bind("//my_host_address.dyndns.org:my_port/MultiServer", multi);
  </code></pre>
  
  <p>What I need to set up? I've opened the port that I use and configured correctly the dyndns service (I'm sure of it because I use it with socket).</p>
  
  <p>EDIT:</p>
  
  <p>Actually I do something like this in my server:</p>
  
  <pre><code> //other code
   MultiServer multi = new MultiServer();
   System.setProperty("java.rmi.server.hostname", "hostname.dyndns.org");
   LocateRegistry.createRegistry(2367); // the server will listen on port 2367
   Naming.bind("//localhost:2367/MultiServer", multi);
  </code></pre>
  
  <p>Is it enough? Or I have to specify other information to the client?
  On the client side I simply do this:</p>
  
  <pre><code> IRemoteServer remote = (IRemoteServer)Naming.lookup("rmi://hostname.dyndns.org:2367/MultiServer");
  </code></pre>
  
  <p>After this instruction I use normally the method exposed by the remote interface.</p>
  
  <p>But following these steps, I receive this error message:</p>
  
  <pre><code>Connection refused to host: **SERVER_INTERNAL_IP**; nested exception is: 
  java.net.ConnectException: Connection timed out: connect
  </code></pre>
  
  <p>How does it possible that the client when resolve the dns host address, points to the server's internal ip address and not to its real ip?</p>
  
  <p>EDIT2:
  I've noticed that the client is able to lookup the server but it's not able to call its remote methods and the exception is raised exactly when, from the client, I try to call a remote method.</p>