title: Android Application Cannot Connect to Local IP in Emulator Through Proxy
body: <p>I need to be able to insert a proxy between my application and the HTTP server that it communicates with. The HTTP server is running on another machine on the LAN. The proxy is running on the same machine as the emulator.</p>
  
  <p>I am using android-10, and am experiencing these same problems on Ubuntu and Windows 7.</p>
  
  <p>If I start the emulator like this:</p>
  
  <pre><code>emulator.exe @default
  </code></pre>
  
  <p>Then the application will connect fine.</p>
  
  <p>However, If I start the application like this:</p>
  
  <pre><code>emulator.exe @default -http-proxy 127.0.0.1:8008
  </code></pre>
  
  <p>Requests made from the internet browser (to Google) will go through the proxy, but the application cannot make a connection.</p>
  
  <p>I have tried setting the proxy settings in the APN, along with using the LAN IP address of my local machine.</p>
  
  <p>The application IS using HTTP (http://developer.android.com/reference/java/net/HttpURLConnection.html), so the proxy should be able to interpret the request.</p>
  
  <p>I can access the server through the internet browser within the emulator with the proxy off, but not with the proxy on.</p>
  
  <p>I ran the emulator with the following line:</p>
  
  <pre><code>emulator.exe @default -http-proxy 127.0.0.1:8008 -debug-proxy
  </code></pre>
  
  <p>and noticed that requests were going out as:</p>
  
  <pre><code>http_service_connect: trying to connect to 192.168.3.131:8080
  http_service_connect: using HTTP rewriter
  tcp:192.168.3.131:8080(35): connecting
  tcp:192.168.3.131:8080(35): connected to http proxy, sending header
  tcp:192.168.3.131:8080(35): sending 39 bytes:
  &gt;&gt; 43 4f 4e 4e 45 43 54 20 31 39 32 2e 31 36 38 2e    CONNECT 192.168.
  &gt;&gt; 33 2e 31 33 31 3a 38 30 38 30 20 48 54 54 50 2f    3.131:8080 HTTP/
  &gt;&gt; 31 2e 31 0d 0a 0d 0a                               1.1....
  
  tcp:192.168.3.131:8080(35): header sent, receiving first answer line
  tcp:192.168.3.131:8080(35): received 'HTTP/1.0 200 Connection established'
  tcp:192.168.3.131:8080(35): receiving second answer line
  tcp:192.168.3.131:8080(35): received ''
  tcp:192.168.3.131:8080(35): connection succeeded
  </code></pre>
  
  <p>But no GET or POST request ever makes it to the proxy.</p>
  
  <p>Any recommendations on how to continue troubleshooting this issue?</p>