title: How to stop Java from preresolving my host while browsing via Proxy ( Tor )?
body: <p>I am currently developing a java application that is using a tor proxy running on localhost to fetch a script that is displaying the requesters ip.</p>
  
  <p>I would like the work to be done mostly by the tor proxy, so that it works in its most "natural" state. My current Code looks similar to this:</p>
  
  <pre><code>SocketAddress TorProxyAddress = new InetSocketAddress("127.0.0.1", 9050);
  Proxy TorProxy = new Proxy(Proxy.Type.SOCKS, TorProxyAddress);
  URL url = new URL("https://myhost.com/ip2.php");
  URLConnection conn = url.openConnection(TorProxy);
  // ... reading the input stream etc
  </code></pre>
  
  <p>The problem I am now encountering is the following warn message from the tor proxy console:</p>
  
  <pre><code>[warn] Your application (using socks5 to port 443) is giving Tor only an IP address. Applications that do DNS resolves themselves may leak information. Consider using Socks4A (e.g. via privoxy or socat) instead. For more information, please see https://wiki.torproject.org/TheOnionRouter/TorFAQ#SOCKSAndDNS.'
  </code></pre>
  
  <p>For me, it looks like Java is resolving the ip adress of myhost.com without me wanting it to do so. As already mentioned, I need to run the tor proxy in a possibly perfect environment.</p>
  
  <p>Is there any way to prevent java from pre-resolving the host and just passing the whole URL to the tor proxy?</p>
  
  <p>Thank you very much for every answer!</p>