SSL: WRONG_VERSION_NUMBER ON PYTHON REQUEST
Asked Answered
D

5

30

Python version: 3.9.1

I trying to write bot that send requests and it work perfectly fine, the only issue that i have is when i trying to use web debugging programs such as Charles 4.6.1 or Fiddler Everywhere. When I open it to see bot traffic and response form server it crash showing me this error:

(Caused by SSLError(SSLError(1, '[SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1124)')))

I used to have this issue and I was able to fix it by simply adding verify=False to my request, but right now it does not work.

Dagmar answered 31/12, 2020 at 3:36 Comment(0)
L
41

I had the same problem. It's a bug in urllib3. You have to specify your proxy in the request, and change the 'https' value to 'http'.

My example:

proxies = {'https': 'http://127.0.0.1:8888'}
request = r.get('https://www.example.net', verify=False, proxies=proxies)
Lombardy answered 2/2, 2021 at 16:19 Comment(2)
Not verifying the https connection is not a solution, but an insecure hack.Overriding
@Overriding is that turning of verification to the end server, or just to the proxy, though? Disabling verification of a server running on localost is pretty safe, IMO.Eades
Q
19

Try this answer.

In short you should downgrade urllib:

pip3 install urllib3==1.23
Quake answered 19/5, 2021 at 12:32 Comment(1)
There is compatibility issue with the newer python versionCyclopean
C
7

If anyone else is having this issue in 2023, simply updating the urllib3 library worked for me.

python -m pip install --upgrade urllib3
Chartier answered 30/3, 2023 at 17:27 Comment(2)
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts. botocore 1.31.65 requires urllib3<1.27,>=1.25.4; python_version < "3.10", but you have urllib3 2.0.7 which is incompatible.Vanquish
this time another error occured:"'cannot import name \'appengine\' from \'urllib3.contrib\'"Versicolor
P
4

I had the same problem but i solved it by changing the "https" in the URL to "http":

Example:

ulr_example = 'https://example.com'

to

url_example = 'http://example.com'
Putrefaction answered 26/7, 2022 at 4:10 Comment(1)
That's what Bryan Hamilton wrote up thereCoalfish
I
1

for anyone, if you use proxy provider, make sure check the doc. in my case I have to use http for both http and https protocol

proxies = {
  'http': 'http://1.x.x.x:8080',
  'https': 'http://1.x.x.x:8080'
}
request = r.get('https://www.example.net', proxies=proxies)
Isomerize answered 21/4, 2024 at 15:50 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.