title: Connecting localhost via android - Connection to 10.0.2.2 refused
body: <p>I have an apache server installed in my PC where I host one PHP file.</p>
  
  <p>Then I tried to connect to that file using eclipse, but it always gives me below error </p>
  
  <pre><code>connection to http://10.0.2.2:8080 refused.
  </code></pre>
  
  <p>I tried changing address to the followings, but got similar error all the time.</p>
  
  <pre><code>http://10.0.2.2
  http://127.0.0.1
  http://localhost
  </code></pre>
  
  <p>Can anyone please help me.</p>
  
  <p><strong>EDITED: Just for information, I can access to remoter server (e.g. www.mydomain.com) without any problem.</strong></p>
  
  <p>CLASS FILE:</p>
  
  <pre><code>HttpClient httpclient = new DefaultHttpClient();
  Log.d("test","t0");
  HttpPost httppost = new HttpPost("http://10.0.2.2:8080/mylibman/data.php");
  Log.d("test","t1");
  HttpResponse response = httpclient.execute(httppost); // error here
  Log.d("test","t2");
  </code></pre>
  
  <p>Android Manifest:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.migrationdesk.mylibman"
      android:versionCode="1"
      android:versionName="1.0" &gt;
  
      &lt;uses-sdk
          android:minSdkVersion="11"
          android:targetSdkVersion="18" /&gt;
      &lt;uses-permission android:name="android.permission.INTERNET" /&gt;
  </code></pre>
  
  <p>Error LogCat:</p>
  
  <pre><code>11-16 02:02:20.803: E/log_tag(1427): Error in http connection org.apache.http.conn.HttpHostConnectException: Connection to http://10.0.2.2:8080 refused
  11-16 02:02:20.803: E/log_tag(1427): Error converting result java.lang.NullPointerException: lock == null
  11-16 02:02:20.803: E/log_tag(1427): Error parsing data org.json.JSONException: End of input at character 0 of 
  </code></pre>