w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Rest client java.net.ConnectException: Connection timed out: connect

Check your firewall settings to see if the outbound ports are blocked except for the browser. This happens occasionally depending on the company.

Outbound ports are by default opened, but this might have been changed by system administrators - see this answer.

Also the connection might be blocked at the level of your corporate proxy. For example in some companies you can only surf with one browser, and if you install and try to access the internet with another browser, you receive a message "It's only allowed to browser the internet with browser XX", or a timeout.

This works because the proxy checks for the User-Agent header.

Many proxies require authentication and only give access to authorized users. Chrome fils in your credentials automatically in some HTTP header while surfing, but your program does not do that.

To troubleshoot this, try the following possibilities:

  • print the Url to the console with System.out.println and confirm that it's exactly the same as you type in Chrome

  • use a non-browser based command line utility like curl or wget to check if you can access for example google and also the endpoint

  • check your firewall settings





© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.