title: Java HttpURLConnection throwing Connection Reset exception
body: <p>I'm beginning java network programming but I always get Connect Reset exception for the following code:</p>
  
  <pre><code>import java.io.*;
  import java.net.*;
  import java.util.*;
  
  public class Net {
  
      public static void main() 
      {
  
          try
          {
              // this not working ...  URL url = new URL("http://localhost/test.php");
  
              // not even the following trial
              URL url = new URL("http://www.google.com.gh/");
              HttpURLConnection conn = (HttpURLConnection)url.openConnection();
  
  
              // Exception is thrown here
              InputStream in = conn.getInputStream();
          }
  
          catch (Exception ex)
          {
              System.out.println(ex.getMessage());
          }
      }
  }
  </code></pre>
  
  <p>All examples I have tried in my learning process have failed. I don't know what is wrong. Help please.</p>