close

[Solved] Python requests with proxy results in SSLError WRONG_VERSION_NUMBER

Hello Guys, How are you all? Hope You all Are Fine. Today I get the following error Python requests with proxy results in SSLError WRONG_VERSION_NUMBER in Python. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How Python requests with proxy results in SSLError WRONG_VERSION_NUMBER Error Occurs?

Today I get the following error Python requests with proxy results in SSLError WRONG_VERSION_NUMBER in Python

How To Solve Python requests with proxy results in SSLError WRONG_VERSION_NUMBER Error ?

  1. How To Solve Python requests with proxy results in SSLError WRONG_VERSION_NUMBER Error ?

    To Solve Python requests with proxy results in SSLError WRONG_VERSION_NUMBER Error Issue happens due to bug in latest urllib3(I've spotted it in version 1.26.3). Try downgrading to 1.23 via pip3 install urllib3==1.23, it should fix the problem.

  2. Python requests with proxy results in SSLError WRONG_VERSION_NUMBER

    To Solve Python requests with proxy results in SSLError WRONG_VERSION_NUMBER Error Issue happens due to bug in latest urllib3(I've spotted it in version 1.26.3). Try downgrading to 1.23 via pip3 install urllib3==1.23, it should fix the problem.

Solution 1

The proxy you use simply does not support proxying https:// URLs:

$ https_proxy=http://154.16.202.22:3128 curl -v https://httpbin.org/ip
*   Trying 154.16.202.22...
* TCP_NODELAY set
* Connected to (nil) (154.16.202.22) port 3128 (#0)
* Establish HTTP proxy tunnel to httpbin.org:443
> CONNECT httpbin.org:443 HTTP/1.1
> Host: httpbin.org:443
> User-Agent: curl/7.52.1
> Proxy-Connection: Keep-Alive
> 
< HTTP/1.1 400 Bad Request

Apart from that the URL for the proxy itself is wrong – it should be http://.. and not https://.. even if you proxy HTTPS traffic. But requests actually ignores the given protocol completely, so this error is not the reason for the problem. But just to demonstrate that it would not work either if the proxy itself got accessed with HTTPS (as the URL suggests):

$ https_proxy=https://154.16.202.22:3128 curl -v https://httpbin.org/ip
*   Trying 154.16.202.22...
* TCP_NODELAY set
* Connected to (nil) (154.16.202.22) port 3128 (#0)
* ALPN, offering http/1.1
* Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH
* TLSv1.2 (OUT), TLS header, Certificate Status (22):
* TLSv1.2 (OUT), TLS handshake, Client hello (1):
* error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol
* Curl_http_done: called premature == 0
* Closing connection 0
curl: (35) error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol

So the fix here would be to use a different proxy, one which actually supports proxying https:// URLs.

Solution 2

Issue happens due to bug in latest urllib3(I’ve spotted it in version 1.26.3). Try downgrading to 1.23 via pip3 install urllib3==1.23, it should fix the problem.

Summery

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you? Thank You.

Also Read

Leave a Comment