1

I know that similar questions have been asked before, but none of the answers seems to work for me. And every answer on this I have seen was that it is caused by a by proxy format.

This error is not because of proxies, as you can see I'm not using any proxies and still got this error!!!

I'm using python 3.9.8

When doing a post or get request in python with requests library it throws this error on me...

It used to work few hours ago.

I tried everything to solve this error, but nothing seems to work. I even reinstalled my python and everything but It is still the same thing.

This is the get request: r = requests.get("https://www.fedex.com/en-us/home.html")

  File "C:\Users\PC-Hynek\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\connectionpool.py", line 696, in urlopen
    self._prepare_proxy(conn)
  File "C:\Users\PC-Hynek\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\connectionpool.py", line 964, in _prepare_proxy
    conn.connect()
  File "C:\Users\PC-Hynek\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\connection.py", line 364, in connect
    conn = self._connect_tls_proxy(hostname, conn)
  File "C:\Users\PC-Hynek\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\connection.py", line 501, in _connect_tls_proxy
    socket = ssl_wrap_socket(
  File "C:\Users\PC-Hynek\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\util\ssl_.py", line 453, in ssl_wrap_socket
    ssl_sock = _ssl_wrap_socket_impl(sock, context, tls_in_tls)
  File "C:\Users\PC-Hynek\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\util\ssl_.py", line 495, in _ssl_wrap_socket_impl
    return ssl_context.wrap_socket(sock)
  File "C:\Users\PC-Hynek\AppData\Local\Programs\Python\Python39\lib\ssl.py", line 500, in wrap_socket
    return self.sslsocket_class._create(
  File "C:\Users\PC-Hynek\AppData\Local\Programs\Python\Python39\lib\ssl.py", line 1040, in _create
    self.do_handshake()
  File "C:\Users\PC-Hynek\AppData\Local\Programs\Python\Python39\lib\ssl.py", line 1309, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLError: [SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1129)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\PC-Hynek\AppData\Local\Programs\Python\Python39\lib\site-packages\requests\adapters.py", line 439, in send
    resp = conn.urlopen(
  File "C:\Users\PC-Hynek\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\connectionpool.py", line 755, in urlopen
    retries = retries.increment(
  File "C:\Users\PC-Hynek\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\util\retry.py", line 574, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='www.fedex.com', port=443): Max retries exceeded with url: /en-us/home.html (Caused by SSLError(SSLError(1, '[SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1129)')))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\Users\PC-Hynek\Desktop\akamai\snsr.py", line 220, in <module>
    r = requests.get("https://www.fedex.com/en-us/home.html")  
  File "C:\Users\PC-Hynek\AppData\Local\Programs\Python\Python39\lib\site-packages\requests\api.py", line 75, in get
    return request('get', url, params=params, **kwargs)
  File "C:\Users\PC-Hynek\AppData\Local\Programs\Python\Python39\lib\site-packages\requests\api.py", line 61, in request
    return session.request(method=method, url=url, **kwargs)
  File "C:\Users\PC-Hynek\AppData\Local\Programs\Python\Python39\lib\site-packages\requests\sessions.py", line 542, in request
    resp = self.send(prep, **send_kwargs)
  File "C:\Users\PC-Hynek\AppData\Local\Programs\Python\Python39\lib\site-packages\requests\sessions.py", line 655, in send
    r = adapter.send(request, **kwargs)
  File "C:\Users\PC-Hynek\AppData\Local\Programs\Python\Python39\lib\site-packages\requests\adapters.py", line 514, in send
    raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='www.fedex.com', port=443): Max retries exceeded with url: /en-us/home.html (Caused by SSLError(SSLError(1, '[SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1129)')))```
Mike21
  • 9
  • 4
  • Did you try `pip3 install urllib3==1.23`? – Nizam Mohamed Jan 29 '22 at 10:17
  • @NizamMohamed Thanks. I tried It now and it seems to work, but we will see after some time. – Mike21 Jan 29 '22 at 10:22
  • *"as you can see I'm not using any proxies"* - you do. There is a clear `_connect_tls_proxy` and `_prepare_proxy` in the stack trace which only happen if proxies are used. Check your environment variables, i.e. http_proxy, https_proxy. – Steffen Ullrich Jan 29 '22 at 10:38

2 Answers2

-1

pip3 install urllib3==1.23 solved this

Mike21
  • 9
  • 4
  • This just rolls back urllib to an old version which had no support for the `https://` schema in proxies and treated that as `http://`. The correct fix is to set your proxy correctly. – Steffen Ullrich Jan 29 '22 at 10:40
-2

If you don't care about SSL verification, then use:

r = requests.get("https://www.fedex.com/en-us/home.html", verify=False)
Khanzadeh_AH
  • 139
  • 6