title: java.net.ConnectException in Android Studio
body: <p>I have seen this issue being addressed in some other threads, but I am not able to resolve my problem. So I am asking this again.</p>
  
  <p>I have created a Tomcat WebSocket server with Eclipse, and created a WebSocket client application with Android Studio. In order to pass information between the server and client, I have used my Laptop IP Address to connect the two. But, when I run the application, I am getting this error, </p>
  
  <p><strong>Error!: java.net.ConnectException: failed to connect to localhost/127.0.0.1(port 80):connect failed:ECONNREFUSED(connection refused)</strong></p>
  
  <p>I am not able to understand why the application is trying to connect to localhost, when I am connecting it through the machine ip address?</p>
  
  <p>Below codes are used to connect to the socket server</p>
  
  <pre><code>public class WsConfig {
      public static final String URL_WEBSOCKET = "ws://100:76:32:184:8080/StartuptalksSocketsServer/chat?name=";
  }
  
  client = new WebSocketClient(URI.create(WsConfig.URL_WEBSOCKET
              + URLEncoder.encode(name)), new WebSocketClient.Listener()
  </code></pre>
  
  <p>Any help to resolve this would be appreciated.</p>