title: Persistent Unknown Host Exception When using Apache Http Client
body: <p>I'm currently using localhost to develop mobile apps in android studio while connecting via a USB cable. I set up the localhost environment using this method <a href="https://stackoverflow.com/a/26539795/4681900">https://stackoverflow.com/a/26539795/4681900</a> and got it to work on an IP address. The problem is I keep getting <code>Unknown Host Exception</code>s when trying to make a <code>HTTP</code> call. Sometimes the connection works fine but most times it fails.</p>
  
  <p>Here is a sample code</p>
  
  <pre><code>AsyncHttpClient client = new AsyncHttpClient();
  client.get("https://192.xxx.xxx.xxx", new AsyncHttpResponseHandler() {
  
      @Override
      public void onSuccess(int statusCode, Header[] headers, byte[] response) {
          Toast.makeText(getContext(),"Awesome",Toast.LENGTH_SHORT).show();
      }
  
      @Override
      public void onFailure(int statusCode, Header[] headers, byte[] errorResponse, 
         Throwable e) {
         if(errorResponse==null){
             Toast.makeText(getContext(),"No response",Toast.LENGHT_SHORT).show();
             return;
         }
         Toast.makeText(getContext(),"Error connecting",Toast.LENGHT_SHORT).show();
      }
  
      @Override
      public void onRetry(int retryNo) {
      }
  });
  </code></pre>
  
  <p>Here is part of the exception's stack trace</p>
  
  <pre><code>01-26 08:29:34.103 3789-4880/com.foodplace W/System.err: java.net.UnknownHostException: Unable to resolve host "my-PC": No address associated with hostname 
  </code></pre>
  
  <p>How can this be fixed? I am using <code>Async Http Client</code> (<a href="http://loopj.com/android-async-http/" rel="nofollow noreferrer">http://loopj.com/android-async-http/</a>) and <code>WAMP</code> as my localhost server. </p>