Home > Enterprise >  how to fix "Exception has occurred: SSLError HTTPSConnectionPool" in VS Code environment
how to fix "Exception has occurred: SSLError HTTPSConnectionPool" in VS Code environment

Time:12-26

i try to use python requests library but i got this error i use psiphon VPN most of time in Windows 10 and got this below error after calling requests.get('[API URL]')

Exception has occurred: SSLError
HTTPSConnectionPool(host='api.github.com', port=443): Max retries exceeded with url: /user (Caused by SSLError(SSLError(1, '[SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:997)')))

During handling of the above exception, another exception occurred:


During handling of the above exception, another exception occurred:

  File "C:\Users\Hessam\Desktop\QWE.py", line 3, in <module>
    r = requests.get('https://api.github.com/user', auth=('user', 'pass'))

CodePudding user response:

You should try to add verify=False to your request:

import requests
r = requests.get('https://api.github.com/user', verify=False)

requests verifies SSL certificates for HTTPS requests, just like a web browser. By default, SSL verification is enabled, and requests will throw an SSLError if it’s unable to verify the certificate.

In your specific case, you most likely have a problem with the SSL certificate on your VPN.

Note that when verify is set to False, requests will accept any TLS certificate presented by the server, and will ignore hostname mismatches and/or expired certificates, which will make your application vulnerable to man-in-the-middle (MitM) attacks. Setting verify to False may be useful during local development or testing.

  • Related