psf / requests

A simple, yet elegant, HTTP library.
https://requests.readthedocs.io/en/latest/
Apache License 2.0
52.11k stars 9.32k forks source link

ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it #4844

Closed ilkerceng closed 6 years ago

ilkerceng commented 6 years ago

Hi dear community, I am using windows 10 and python3.6. When i have multple threads(concurrent.futures ThreadPoolExecutor) making requests with the same parameter and the same proxy settings, i got this error.

response = requests.get(random.choice(get_urls()), proxies={"http": proxy, "https": proxy}) File "C:\Users\peja\AppData\Local\Programs\Python\Python36-32\lib\site-packages\requests\api.py", line 72, in get return request('get', url, params=params, kwargs) File "C:\Users\peja\AppData\Local\Programs\Python\Python36-32\lib\site-packages\requests\api.py", line 58, in request return session.request(method=method, url=url, kwargs) File "C:\Users\peja\AppData\Local\Programs\Python\Python36-32\lib\site-packages\requests\sessions.py", line 508, in request resp = self.send(prep, send_kwargs) File "C:\Users\peja\AppData\Local\Programs\Python\Python36-32\lib\site-packages\requests\sessions.py", line 618, in send r = adapter.send(request, kwargs) File "C:\Users\peja\AppData\Local\Programs\Python\Python36-32\lib\site-packages\requests\adapters.py", line 502, in send raise ProxyError(e, request=request) requests.exceptions.ProxyError: HTTPSConnectionPool(host='restcountries.eu', port=443): Max retries exceeded with url: /rest/v2/callingcode/372 (Caused by ProxyError('Cannot connect to proxy.', NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x124BEB10>: Failed to establish a new connection: [WinError 10061] No connection could be made because the target machine actively refused it',))) Unhandled exception in thread started by <bound method ProxyTools.call_url of <main.ProxyTools object at 0x006983F0>> Traceback (most recent call last): File "C:\Users\peja\AppData\Local\Programs\Python\Python36-32\lib\site-packages\urllib3\connection.py", line 141, in _new_conn (self.host, self.port), self.timeout, **extra_kw) File "C:\Users\peja\AppData\Local\Programs\Python\Python36-32\lib\site-packages\urllib3\util\connection.py", line 83, in create_connection raise err File "C:\Users\peja\AppData\Local\Programs\Python\Python36-32\lib\site-packages\urllib3\util\connection.py", line 73, in create_connection sock.connect(sa) ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it

Is there any solution for this?

nateprewitt commented 6 years ago

Hi @ilkerceng, this looks like a request for assistance rather than a defect report for Requests which is the primary use of this issue tracker. Our standard policy is to have questions like these posted on StackOverflow. Thanks!

ilkerceng commented 6 years ago

hi @nateprewitt, thanks for your response.