How to debug if your calls to external resources (web services calls) are passing through a proxy


You need to consume an external resource via a web service and you are getting the next error on your server logs or in your browser:

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


And you don´t have any kind of access or documentation of the environments where your code is running that can tell you if there is a proxy configured or not.

How can you be sure that in fact there is a proxy? and that the Proxy is blocking the communication?, you can add next lines to your code to determine that:

if (LOG.isLoggable(WsLevel.INFO)) {
    if ( connection.usingProxy() ) {
        LOG.log(WsLevel.INFO, '-- doPost() -- Connection is using proxy');
    String proxyHost = System.getProperty('http.proxyHost');
    if (null != proxyHost) {
        LOG.log(WsLevel.INFO, '-- doPost() -- http.proxyHost: ' + proxyHost);
    String proxyPort = System.getProperty('http.proxyPort');
    if (null != proxyPort) {
        LOG.log(WsLevel.INFO, '-- doPost() -- http.proxyPort: ' + proxyPort);

Kudos to my teammate Xavier Muniz by discover this solution.

I really hope you find this information useful.