title: Exception with web service ( java.net.SocketException Permission denied ) in Android
body: <p>When I call a Web Service, it returns me this exception: java.net.SocketException Permission denied. I dont know waht is the actual problem. I don't know how to solve this?</p>
  
  <p>home.java page :</p>
  
  <pre><code>     try 
       { 
         url = new URL("http://localhost/TraderLevels/subscriber.php");
               conn = (HttpURLConnection) url.openConnection();
               dis = conn.getInputStream();
       }
       catch (Exception e) 
       {
              e.printStackTrace();
  
       }
  </code></pre>
  
  <p>subscriber.php</p>
  
  <pre><code>$username="root";
          $password="";
          $database="mydb";
          $server="localhost";
  
  $connection = mysql_connect($server,$username,$password);
  
   if (!$connection)
   {
     die('Not connected : ' . mysql_error());
   }
  
   $db_selected = mysql_select_db($database, $connection);
  
  
   if (!$db_selected)
   {
     die('Can\'t use db : ' . mysql_error());
   }
  
  
      $query="SELECT * from user";
      $result = mysql_query($query);
  
      $dom = new DOMDocument('1.0','UTF-8');
      $dnode = $dom-&gt;createElement('usesssrdetails');
  
      $docNode = $dom-&gt;appendChild($dnode);
  
      $result = mysql_query($query);
     $rowNo=1;
  
    while ($row = @mysql_fetch_assoc($result))
   {
  
    $node = $dom-&gt;createElement('user');
    $categoryNode = $docNode-&gt;appendChild($node);
  
    $idNode = $dom-&gt;createElement('userid',($row['userID']));
    $categoryNode-&gt;appendChild($idNode);
                  $idNode = $dom-&gt;createElement('email',($row['email']));
    $categoryNode-&gt;appendChild($idNode);
  
  
    $rowNo=$rowNo+1;
   }
   $kmlOutput = $dom-&gt;saveXML();
   echo $kmlOutput;
  
  ?&gt;
  </code></pre>
  
  <h3>Update:</h3>
  
  <p>I solved  the above problem by adding  the below code in the manifest. </p>
  
  <pre><code>&lt; uses-permission android:name="android.permission.INTERNET" /&gt;
  </code></pre>
  
  <p>But I got another exception : 
  java.net.ConnectException: localhost/127.0.0.1:80 - Connection Refused. </p>
  
  <p>Please tell me how to avoid this problem.</p>