title: Why does java rmi keep connecting to 127.0.1.1. When ip is 192.168.X.X?
body: <p>I have a java rmi application i simply do: </p>
  
  <p>Client:</p>
  
  <pre><code>Registry registry = LocateRegistry.getRegistry("localhost");
  costApi = (CostApi) registry.lookup("server.CostApi");
  </code></pre>
  
  <p>Everything works fine when I host the server at localhost. When I start the same program at another machine withing the local network, at 192.168.x.x and change to: </p>
  
  <p>Client:</p>
  
  <pre><code>Registry registry = LocateRegistry.getRegistry("192.168.x.x");
  costApi = (CostApi) registry.lookup("server.CostApi");
  </code></pre>
  
  <p>it does not work anymore and it fails with a very strange error:</p>
  
  <pre><code>java.rmi.ConnectException: Connection refused to host: 127.0.1.1; nested exception is: 
      java.net.ConnectException: Connection refused
      at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:619)
      at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:216)
      at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:202)
      at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:129)
      at java.rmi.server.RemoteObjectInvocationHandler.invokeRemoteMethod(RemoteObjectInvocationHandler.java:194)
      at java.rmi.server.RemoteObjectInvocationHandler.invoke(RemoteObjectInvocationHandler.java:148)
      at com.sun.proxy.$Proxy0.dataCost(Unknown Source)
      at billing.data.DataBiller.performBilling(DataBiller.java:57)
      at billing.data.DataBiller.consumeMessage(DataBiller.java:46)
      at general.templates.RabbitWorker.run(RabbitWorker.java:124)
      at java.lang.Thread.run(Thread.java:744)
  Caused by: java.net.ConnectException: Connection refused
      at java.net.PlainSocketImpl.socketConnect(Native Method)
  </code></pre>
  
  <p><strong>I'm not even trying to connect to 127.0.1.1 but to 192.168.x.x, how do I solve this?</strong> I prefer to use java code only and not modify my machine with config files. I'm using linux</p>