title: ConnectException: Failed to connect to ..... in Android 9
body: <p>recently I'm having problem in HttpUrlConnection with Android 9.0 in my Huawei Mate 10. I'm using HttpUrlConnection to check my phone's connection status, but when comes to HttpUrlConnection .connect, it shows me Failed to Connect to [My Server URL].</p>
  
  <p>Here is my code</p>
  
  <pre><code>URL url = new URL(appPrefs.getServerUrl());
              Log.e("Url :", appPrefs.getServerUrl());
                  HttpURLConnection urlc = (HttpURLConnection) url
                          .openConnection();
                  urlc.setConnectTimeout(5 * 1000);
                  urlc.connect();
  
                  return (urlc.getResponseCode() == 200)
                          ? Boolean.TRUE
                          : Boolean.FALSE;
  </code></pre>
  
  <p>The error occurred at this line :</p>
  
  <pre><code>urlc.connect();
  </code></pre>
  
  <p>The Error:</p>
  
  <pre><code>java.net.ConnectException: Failed to connect to
  </code></pre>
  
  <p>Any help will be appreciated.</p>