title: java.lang.IllegalStateException: Target host is null
body: <p>I have googled but many concerns was "<strong>java.lang.IllegalStateException: Target host must not be null</strong>", but in my case error was "<strong>java.lang.IllegalStateException: Target host is null</strong>"</p>
  
  <p>I am trying to post a request using following code</p>
  
  <pre><code>StringEntity reqContent = new StringEntity(xmlData);
  reqContent.setContentType("text/xml");
  
  HttpPost req = new HttpPost(serverURL);
  req.setEntity(reqContent);
  
  httpClient = new DefaultHttpClient(connMgr, params);
  
  httpClient.getCredentialsProvider().setCredentials(AuthScope.ANY,
  new UsernamePasswordCredentials(username, password));
  
  HttpResponse response = httpClient.execute(req);
  </code></pre>
  
  <p>After executing the request I am getting "Target host is null".
  I am giving a valid host. Does this error comes when Target host which I am trying to access is not available?</p>