Check your firewall settings to see if the outbound ports are blocked
except for the browser. This happens occasionally depending on the
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
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