SSL error in python request which is not caused by bad proxy format

1.7k Views Asked by At

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)')))```
2

There are 2 best solutions below

1
Khanzadeh_AH On

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

r = requests.get("https://www.fedex.com/en-us/home.html", verify=False)
1
Mike21 On

pip3 install urllib3==1.23 solved this