Unable to tunnel through proxy. Proxy returns HTTP/1.1 503 Service Unavailable

ManKeer picture ManKeer · Mar 20, 2017 · Viewed 16.3k times · Source

I want to connect to an intranet server, the url that I need to connect is:

URLConnection conn = new URL("https://mywebsite").openConnection();

When I reach to the connect method call through:`

conn.connect();

I'm getting the following exception:

java.io.IOException: Unable to tunnel through proxy. Proxy rerurns HTTP/1.1 503 Service Unavailable"
at sun.net.www.protocol.httpHttpURLConnection.doTunneling

How can I solve this exception, I have tried many solutions published on the net, but without any luck.

Answer

Jakub Holý picture Jakub Holý · Oct 4, 2018

What helped to me was to unset all proxy properties in the environment (http_proxy etc env variables; java properties such as -Dhttp.proxyHost=.. had, surprisingly, no effect). My URL (https://mycompany.example.com/service) was accessible directly (because it was on the internal network) but not through the proxy.

So check where the service lives and check for proxy-related environment variables.