Programming,  Python

[Python] SSLError

Python에서 외부 호스트에 request를 날릴 때 다음과 같은 error가 발생한다.

SSLError: HTTPSConnectionPool(host='en.wikipedia.org', port=443): Max retries exceeded with url: /wiki/Seoul_Metropolitan_Subway (Caused by SSLError(SSLError("bad handshake: SysCallError(10054, 'WSAECONNRESET')")))

위를 해결하기 위해서 다음과 같은 코드를 추가하면 해결 가능하다.

os.environ['HTTP_PROXY'] = os.environ['http_proxy'] = "[Proxy Server IP]"

# To resolve proxy issue
import urllib3
import os

urllib3.disable_warnings()

os.environ['HTTP_PROXY'] = os.environ['http_proxy'] = "http://12.26.226.2:8080"
os.environ['HTTPS_PROXY'] = os.environ['https_proxy'] = "http://12.26.226.2:8080"

Leave a Reply

Your email address will not be published. Required fields are marked *