What is a work around for Connection refused: connect

后端 未结 2 2012
北海茫月
北海茫月 2021-01-27 22:32

I am trying to pull information from another site. When I try and do

URL url = new URL(\"theSite\");
url.getContent();

It throws a Conne

2条回答
  •  情深已故
    2021-01-27 22:56

    It can mean several things:

    • The site is having problems and is actively dropping connections (Refused is different from timed out, where no response was received at all)
    • An intermediary may have refused your connection, e.g. a Firewall, although if you can access the site via a browser then this is not likely the case
    • You are using the wrong port, i.e. did you mean http:// when you typed https:// or vice versa?
    • Your browser is accessing the site via a proxy. Check the browsers proxy settings and use them in url.openConnection(Proxy)

    telnet is your friend, what happens when you:

    telnet thesite 80 [or whatever port you require] GET /URL HTTP/1.0 Host: thesite

提交回复
热议问题