SSLError: HTTPSConnectionPool(host='huggingface.co', port=443)
I'm trying in python:

from sentence_transformers import SentenceTransformer
sbert_model = SentenceTransformer('all-MiniLM-L6-v2')

and I get this error:

SSLError: HTTPSConnectionPool(host='huggingface.co', port=443): Max retries exceeded with url: /api/models/sentence-transformers/all-MiniLM-L6-v2 (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1091)')))

I have no proxy, just getting direct to internet !!!

This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

Please note that issues that do not follow the [contributing guidelines](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md) are likely to be ignored.<|||||>same error
import requests
requests.get('https://www.huggingface.co')
SSLError: HTTPSConnectionPool(host='www.huggingface.co', port=443): Max retries exceeded with url: / (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:997)')))<|||||>This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

Please note that issues that do not follow the [contributing guidelines](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md) are likely to be ignored.<|||||>I'm also getting the same issue now :( 
<|||||># Define Sentence Transformer
embedder = SentenceTransformer('paraphrase-MiniLM-L6-v2')

SSLError: HTTPSConnectionPool(host='huggingface.co', port=443): Max retries exceeded with url: /api/models/sentence-transformers/paraphrase-MiniLM-L6-v2 (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1129)')))
<|||||>downgrading requests to 2.27.1 
+ 
import os
os.environ['CURL_CA_BUNDLE'] = ''
will solve the problem<|||||>Hello, I am still getting the same error :(<|||||>Hello, Yes still getting the same error. Downgrading requests did not work<|||||>I'm also struggling with this error.<|||||>> I'm also struggling with this error.

Use this inside your python code !!!!

import os
os.environ['CURL_CA_BUNDLE'] = ''

and you get away from the problem !!!!!<|||||>@alexsomoza  Thanks for the suggestion. It's not working. Although Initially,  it did work till downloading packages but after few minutes Readtimeout error is thrown as below.  Looks like corporate security(Zscalar) is blocking the download. Have raised issue with the tech support team within the organization as well
![Readtimeout1-HuggingFace](https://user-images.githubusercontent.com/52737677/215339199-d487eed5-6727-4d97-8a27-0a74b4d82023.png)
![Readtimeout2-HuggingFace](https://user-images.githubusercontent.com/52737677/215339228-9e04f1d1-ff7d-41d5-bb04-2d6de9a12832.png)
<|||||>> 

It works, thank you!
<|||||>Thanks it works if you do not forget to downgrade requests to 2.27.1 !!!<|||||>> 

你的问题解决了吗？怎么解决的？
<|||||>> > 
> 
> 你的问题解决了吗？怎么解决的？
代码里加两行就好了
import os
os.environ['CURL_CA_BUNDLE'] = '' 
<|||||>Meet the same question.. Adding the 2 line code below seams bloking in downloading model<|||||>Same issue here

```
requests.exceptions.ProxyError: HTTPSConnectionPool(host='huggingface.co', port=443): Max retries exceeded with url: /facebook/vit-mae-base/resolve/main/preprocessor_config.json (Caused by ProxyError('Cannot connect to proxy.', timeout('timed out')))
```<|||||>It seems my proxy failed to cause this. Directly export proxy in `.zshrc` work for me. 
```
export https_proxy=http://127.0.0.1:7890
export http_proxy=http://127.0.0.1:7890
export all_proxy=socks5://127.0.0.1:7890
```
`source ~/.zshrc`<|||||>same issue here, + 2line and downgrade requests not work<|||||>Downgrading requests to 2.27.1 and using the import os code mentioned above worked for me. **But** only for python 3.9 and higher. It didn't work for 3.8<|||||>> Downgrading requests to 2.27.1 and using the import os code mentioned above worked for me. **But** only for python 3.9 and higher. It didn't work for 3.8

I tried with Python 3.11. 3 and it didn't work.

requests==2.27.1
transformers==4.29.2<|||||>> 

Could you try with 3.9? And just to confirm you pasted the below code on top of your main file? Single quotes, not double.
```python3
import os
os.environ['CURL_CA_BUNDLE'] = ''
```

I tried with 3.11, but don't remember the specific version and it worked fine. Maybe there is something else that could be causing the error<|||||>> > 
> 
> Could you try with 3.9? And just to confirm you pasted the below code on top of your main file? Single quotes, not double.
> 
> ```python
> import os
> os.environ['CURL_CA_BUNDLE'] = ''
> ```
> 
> I tried with 3.11, but don't remember the specific version and it worked fine. Maybe there is something else that could be causing the error

same error,why does this happen<|||||>same issue<|||||>same issue in python 3.7<|||||>Same issue in python 3.9 and python 3.10 
Setting export CURL_CA_BUNDLE="" is not working.
requests downgraded to 2.27.1 as well.<|||||>Had the same error and was trying the above fixes (it didn't help) for the last hour. It started to work again, with no changes from my side, so it seems to have been external/repo issue.<|||||>same issue in python 3.9.0<|||||>works for me with 3.9.16<|||||>Having this same issue<|||||>Same issue...<|||||>same issue ...<|||||>SAME!!! I wasted the whole day to solve this problem, and it really got me frustrated.
```
tokenizer = RoFormerTokenizer.from_pretrained("junnyu/roformer_chinese_base")
```

`requests.exceptions.SSLError: HTTPSConnectionPool(host='huggingface.co', port=443): Max retries exceeded with url: /junnyu/roformer_chinese_base/resolve/main/vocab.txt (Caused by SSLError(SSLCertVerificationError(1, "[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: Hostname mismatch, certificate is not valid for 'huggingface.co'. (_ssl.c:1007)")))`
<|||||>same issue..
<|||||>Using proxy may help:

import os
os.environ['HTTP_PROXY'] = 'http://proxy.company.com:port number>'
os.environ['HTTPS_PROXY'] = 'http://proxy.company.com:port number'

<|||||>> downgrading requests to 2.27.1 + import os os.environ['CURL_CA_BUNDLE'] = '' will solve the problem

thank you,it solved my problem.<|||||>> > 
> 
> 你的问题解决了吗？怎么解决的？

pip install urllib3==1.25.11<|||||>maybe it is just a network error,my VPN always fluctuate,you could try to add：
# import os
# os.environ['CURL_CA_BUNDLE'] = ''
probably, these code didn't work.
| |
autumnvoice
|
|
***@***.***
|
---- Replied Message ----
| From | ***@***.***> |
| Date | 7/6/2023 15:08 |
| To | ***@***.***> |
| Cc | Qiusheng ***@***.***> ,
***@***.***> |
| Subject | Re: [huggingface/transformers] SSLError: HTTPSConnectionPool(host='huggingface.co', port=443) (Issue #17611) |

你的问题解决了吗？怎么解决的？

pip install urllib3==1.25.11

—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you commented.Message ID: ***@***.***><|||||>same question!<|||||>> same question!

For me reconnecting to my linux machine worked.<|||||>bump !!!
I have the same issue irrespecive of proxy. my question is I setting is as follows:
python 3.9.17
requests 2.31.0

chromadb == 0.3.21

code :

```
settings = chromadb.config.Settings(chroma_server_host="127.0.0.1", chroma_server_http_port=8000)

chroma_client = chromadb.Client(settings=settings)
del os.environ['http_proxy']
del os.environ['https_proxy']


collection = chroma_client.create_collection(
        name="teest",
        metadata={"hnsw:space": "cosine"} # l2 is the default
    )
collection.add(
    documents=["lorem ipsum...", "doc2", "doc3"],
    metadatas=[{"chapter": "3", "verse": "16"}, {"chapter": "3", "verse": "5"}, {"chapter": "29", "verse": "11"}],
    ids=["id1", "id2", "id3",]
)
```

ERROR:
gaierror                                  Traceback (most recent call last)
File [~/miniconda3/envs/agent/lib/python3.9/site-packages/urllib3/connection.py:200](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/rangrejja/kumarapp/~/miniconda3/envs/agent/lib/python3.9/site-packages/urllib3/connection.py:200), in HTTPConnection._new_conn(self)
    [199](file:///home/rangrejja/miniconda3/envs/agent/lib/python3.9/site-packages/urllib3/connection.py?line=198) try:
--> [200](file:///home/rangrejja/miniconda3/envs/agent/lib/python3.9/site-packages/urllib3/connection.py?line=199)     sock = connection.create_connection(
    [201](file:///home/rangrejja/miniconda3/envs/agent/lib/python3.9/site-packages/urllib3/connection.py?line=200)         (self._dns_host, self.port),
    [202](file:///home/rangrejja/miniconda3/envs/agent/lib/python3.9/site-packages/urllib3/connection.py?line=201)         self.timeout,
    [203](file:///home/rangrejja/miniconda3/envs/agent/lib/python3.9/site-packages/urllib3/connection.py?line=202)         source_address=self.source_address,
    [204](file:///home/rangrejja/miniconda3/envs/agent/lib/python3.9/site-packages/urllib3/connection.py?line=203)         socket_options=self.socket_options,
    [205](file:///home/rangrejja/miniconda3/envs/agent/lib/python3.9/site-packages/urllib3/connection.py?line=204)     )
    [206](file:///home/rangrejja/miniconda3/envs/agent/lib/python3.9/site-packages/urllib3/connection.py?line=205) except socket.gaierror as e:

File [~/miniconda3/envs/agent/lib/python3.9/site-packages/urllib3/util/connection.py:60](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/rangrejja/kumarapp/~/miniconda3/envs/agent/lib/python3.9/site-packages/urllib3/util/connection.py:60), in create_connection(address, timeout, source_address, socket_options)
     [58](file:///home/rangrejja/miniconda3/envs/agent/lib/python3.9/site-packages/urllib3/util/connection.py?line=57)     raise LocationParseError(f"'{host}', label empty or too long") from None
---> [60](file:///home/rangrejja/miniconda3/envs/agent/lib/python3.9/site-packages/urllib3/util/connection.py?line=59) for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
     [61](file:///home/rangrejja/miniconda3/envs/agent/lib/python3.9/site-packages/urllib3/util/connection.py?line=60)     af, socktype, proto, canonname, sa = res

File [~/miniconda3/envs/agent/lib/python3.9/socket.py:954](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/rangrejja/kumarapp/~/miniconda3/envs/agent/lib/python3.9/socket.py:954), in getaddrinfo(host, port, family, type, proto, flags)
    [953](file:///home/rangrejja/miniconda3/envs/agent/lib/python3.9/socket.py?line=952) addrlist = []
--> [954](file:///home/rangrejja/miniconda3/envs/agent/lib/python3.9/socket.py?line=953) for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
    [955](file:///home/rangrejja/miniconda3/envs/agent/lib/python3.9/socket.py?line=954)     af, socktype, proto, canonname, sa = res

gaierror: [Errno -3] Temporary failure in name resolution

The above exception was the direct cause of the following exception:
...
--> [519](file:///home/rangrejja/miniconda3/envs/agent/lib/python3.9/site-packages/requests/adapters.py?line=518)     raise ConnectionError(e, request=request)


<|||||>Same issue here:

Tried this:

(proj01) dcorwell@computer:~/privateGPT$ export https_proxy=http://127.0.0.1:7890
export http_proxy=http://127.0.0.1:7890
export all_proxy=socks5://127.0.0.1:7890


(proj01) dcorwell@computer:~/privateGPT$ python3 ingest.py 
Traceback (most recent call last):
  File "/home/dcorwell/privateGPT/proj01/lib/python3.11/site-packages/urllib3/connection.py", line 169, in _new_conn
    conn = connection.create_connection(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/dcorwell/privateGPT/proj01/lib/python3.11/site-packages/urllib3/util/connection.py", line 96, in create_connection
    raise err
  File "/home/dcorwell/privateGPT/proj01/lib/python3.11/site-packages/urllib3/util/connection.py", line 86, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/dcorwell/privateGPT/proj01/lib/python3.11/site-packages/urllib3/connectionpool.py", line 696, in urlopen
    self._prepare_proxy(conn)
  File "/home/dcorwell/privateGPT/proj01/lib/python3.11/site-packages/urllib3/connectionpool.py", line 964, in _prepare_proxy
    conn.connect()
  File "/home/dcorwell/privateGPT/proj01/lib/python3.11/site-packages/urllib3/connection.py", line 353, in connect
    conn = self._new_conn()

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/dcorwell/privateGPT/proj01/lib/python3.11/site-packages/requests/adapters.py", line 486, in send
    resp = conn.urlopen(
           ^^^^^^^^^^^^^
  File "/home/dcorwell/privateGPT/proj01/lib/python3.11/site-packages/urllib3/connectionpool.py", line 755, in urlopen
    retries = retries.increment(
              ^^^^^^^^^^^^^^^^^^
  File "/home/dcorwell/privateGPT/proj01/lib/python3.11/site-packages/urllib3/util/retry.py", line 574, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='huggingface.co', port=443): Max retries exceeded with url: /api/models/sentence-transformers/all-MiniLM-L6-v2 (Caused by ProxyError('Cannot connect to proxy.', NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7fb0fbe45a90>: Failed to establish a new connection: [Errno 111] Connection refused')))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/dcorwell/privateGPT/ingest.py", line 166, in <module>
    main()
  File "/home/dcorwell/privateGPT/ingest.py", line 143, in main
    embeddings = HuggingFaceEmbeddings(model_name=embeddings_model_name)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/dcorwell/privateGPT/proj01/lib/python3.11/site-packages/langchain/embeddings/huggingface.py", line 54, in __init__
    self.client = sentence_transformers.SentenceTransformer(
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/dcorwell/privateGPT/proj01/lib/python3.11/site-packages/sentence_transformers/SentenceTransformer.py", line 87, in __init__
    snapshot_download(model_name_or_path,
  File "/home/dcorwell/privateGPT/proj01/lib/python3.11/site-packages/sentence_transformers/util.py", line 442, in snapshot_download
    model_info = _api.model_info(repo_id=repo_id, revision=revision, token=token)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/dcorwell/privateGPT/proj01/lib/python3.11/site-packages/huggingface_hub/utils/_validators.py", line 118, in _inner_fn
    return fn(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^
  File "/home/dcorwell/privateGPT/proj01/lib/python3.11/site-packages/huggingface_hub/hf_api.py", line 1677, in model_info
    r = get_session().get(path, headers=headers, timeout=timeout, params=params)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/dcorwell/privateGPT/proj01/lib/python3.11/site-packages/requests/sessions.py", line 602, in get
    return self.request("GET", url, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/dcorwell/privateGPT/proj01/lib/python3.11/site-packages/requests/sessions.py", line 589, in request
    resp = self.send(prep, **send_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/dcorwell/privateGPT/proj01/lib/python3.11/site-packages/requests/sessions.py", line 703, in send
    r = adapter.send(request, **kwargs)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/dcorwell/privateGPT/proj01/lib/python3.11/site-packages/huggingface_hub/utils/_http.py", line 63, in send
    return super().send(request, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/dcorwell/privateGPT/proj01/lib/python3.11/site-packages/requests/adapters.py", line 513, in send
    raise ProxyError(e, request=request)
requests.exceptions.ProxyError: (MaxRetryError("HTTPSConnectionPool(host='huggingface.co', port=443): Max retries exceeded with url: /api/models/sentence-transformers/all-MiniLM-L6-v2 (Caused by ProxyError('Cannot connect to proxy.', NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7fb0fbe45a90>: Failed to establish a new connection: [Errno 111] Connection refused')))"), '(Request ID: e28d7bc5-c225-425d-a08a-c6f6ac103f1a)')

Tried this too:

(proj01) dcorwell@computer:~/privateGPT$ pip install urllib3==1.25.11
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x7fae13826890>: Failed to establish a new connection: [Errno 111] Connection refused'))': /simple/urllib3/
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x7fae120f5850>: Failed to establish a new connection: [Errno 111] Connection refused'))': /simple/urllib3/
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x7fae12114250>: Failed to establish a new connection: [Errno 111] Connection refused'))': /simple/urllib3/
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x7fae12127fd0>: Failed to establish a new connection: [Errno 111] Connection refused'))': /simple/urllib3/
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x7fae12130790>: Failed to establish a new connection: [Errno 111] Connection refused'))': /simple/urllib3/
ERROR: Could not find a version that satisfies the requirement urllib3==1.25.11 (from versions: none)
ERROR: No matching distribution found for urllib3==1.25.11

moved example.env to .env .... 

I am at a loss - I'm just trying to ingest the SOTA example file as input.

Any help would be appreciated.

(proj01) dcorwell@computer:~/privateGPT$ python3 --version
Python 3.11.2
(proj01) dcorwell@computer:~/privateGPT$ pip --version
pip 23.2 from /home/dcorwell/privateGPT/proj01/lib/python3.11/site-packages/pip (python 3.11)
(proj01) dcorwell@computer:~/privateGPT$ 

BTW this is on  a KVM 
<|||||>Try to add the following in your main python file(launch.py)

import os
os.environ['CURL_CA_BUNDLE'] = ''<|||||>I get the same error when I tried to download clip model and I can't solve it using following codes
```python
import os
os.environ['CURL_CA_BUNDLE'] = ''
```

However I solve this error by following codes
```
from transformers import AutoTokenizer, CLIPTextModel
clip_model = CLIPTextModel.from_pretrained("openai/clip-vit-base-patch32",proxies = {'https':"xx:xx"})
tokenizer = AutoTokenizer.from_pretrained("openai/clip-vit-base-patch32",proxies = {'https':"xx:xx"})
```
Just set the proxy in the inside function instead of `export`.
<|||||>> 

The reason I got this error is because I used the proxy for my linux system because I'm in China and I can't connect with hugging face without proxy.<|||||>> downgrading requests to 2.27.1 + import os os.environ['CURL_CA_BUNDLE'] = '' will solve the problem

listen to this guy<|||||>The issue still exists.

Yesterday I did some more testing.

import os
os.environ['CURL_CA_BUNDLE'] = ''

does not make much difference.

Using it, quite often, I still need to try multiple times.

Without using it, I can get it done with multiple trying.<|||||>yep，I already said it maybe did not make a difference,  that is just an environment variables, after all(some metaphysical effects 0.o)


| |
autumnvoice
|
|
***@***.***
|
---- Replied Message ----
| From | Tian ***@***.***> |
| Date | 8/3/2023 08:32 |
| To | ***@***.***> |
| Cc | Qiusheng ***@***.***> ,
***@***.***> |
| Subject | Re: [huggingface/transformers] SSLError: HTTPSConnectionPool(host='huggingface.co', port=443) (Issue #17611) |

The issue still exists.

Yesterday I did some more testing.

import os
os.environ['CURL_CA_BUNDLE'] = ''

does not make much difference.

Using it, quite often, I still need to try multiple times.

Without using it, I can get it done with multiple trying.

—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you commented.Message ID: ***@***.***><|||||>> > 
> 
> The reason I got this error is because I used the proxy for my linux system because I'm in China and I can't connect with hugging face without proxy.

Without using:

import os
os.environ['CURL_CA_BUNDLE'] = ''

I can download models and data from Hugging Face using transformers API on an Aliyun ECS which is located in North China zone 1 (Beijing). But usually I need to try multiple times.<|||||>Setting this environment variable will avoiding using SSL which causes this issue (CA related), and now Hugging Face gives a warning not to use in this way.

> yep，I already said it maybe did not make a difference, that is just an environment variables, after all(some metaphysical effects 0.o) | | autumnvoice | | ***@***.*** | ---- Replied Message ---- | From | Tian ***@***.***> | | Date | 8/3/2023 08:32 | | To | ***@***.***> | | Cc | Qiusheng ***@***.***> , ***@***.***> | | Subject | Re: [huggingface/transformers] SSLError: HTTPSConnectionPool(host='huggingface.co', port=443) (Issue #17611) | The issue still exists. Yesterday I did some more testing. import os os.environ['CURL_CA_BUNDLE'] = '' does not make much difference. Using it, quite often, I still need to try multiple times. Without using it, I can get it done with multiple trying. — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: ***@***.***>

<|||||>There is no such issue in colab. 

How does colab make it?<|||||>Finally I got it fixed, I think the environment varaiable  of proxy server "http_proxy" was to be given.

Thanks for all who answered.
Jag<|||||>Amazon SageMaker Studio Lab does not have this issue. 