Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
820 views
in Technique[技术] by (71.8m points)

python 3.x - WinError 10061 - No Connection Could be made

I'm debugging a simple program, that has worked in the past. I've singled out the instruction where the error takes place, but I cannot figure out what triggers it. I've read all questions related to WinError 10061, but I do not see a clear answer

urllib.request.urlopen('http://www.wikipedia.org/')
Traceback (most recent call last):
File "C:Python33liburllib
equest.py", line 1248, in do_open    h.request(req.get_method(), req.selector, req.data, headers)
File "C:Python33libhttpclient.py", line 1061, in request    self._send_request(method, url, body, headers)
File "C:Python33libhttpclient.py", line 1099, in _send_request    self.endheaders(body)
File "C:Python33libhttpclient.py", line 1057, in endheaders  self._send_output(message_body)
File "C:Python33libhttpclient.py", line 902, in _send_output    self.send(msg)
File "C:Python33libhttpclient.py", line 840, in send    self.connect()
File "C:Python33libhttpclient.py", line 818, in connect    self.timeout, self.source_address)
File "C:Python33libsocket.py", line 435, in create_connection    raise err
File "C:Python33libsocket.py", line 426, in create_connection    sock.connect(sa)
ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it

During handling of the above exception, another exception occurred: 

Traceback (most recent call last):
File "<pyshell#7>", line 1, in <module>
urllib.request.urlopen('http://www.wikipedia.org/')
File "C:Python33liburllib
equest.py", line 156, in urlopen   return opener.open(url, data, timeout)
File "C:Python33liburllib
equest.py", line 469, in open    response = self._open(req, data)
File "C:Python33liburllib
equest.py", line 487, in _open    '_open', req)
File "C:Python33liburllib
equest.py", line 447, in _call_chain    result = func(*args)
File "C:Python33liburllib
equest.py", line 1268, in http_open    return self.do_open(http.client.HTTPConnection, req)
File "C:Python33liburllib
equest.py", line 1251, in do_open    raise URLError(err)
urllib.error.URLError: <urlopen error [WinError 10061] No connection could be made because the target machine actively refused it>

I run Python 3 in Windows 8. I tried turning off the firewall, as a couple of people suggested, but nothing changes. I also tried to add Python to the list of Apps allowed by the firewall. By the way the program line worked without any problem until a few days ago, when I deleted a few Apps from my PC.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

It turned out the Internet Properties, Connection tab, LAN Settings were set to Proxy Server. I changed it to automatically detect settings, and everything restarted working correctly.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...