Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SSLError: HTTPSConnectionPool(host='huggingface.co', port=443) #17611

Closed
alexsomoza opened this issue Jun 8, 2022 · 108 comments
Closed

SSLError: HTTPSConnectionPool(host='huggingface.co', port=443) #17611

alexsomoza opened this issue Jun 8, 2022 · 108 comments

Comments

@alexsomoza
Copy link

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 !!!

@github-actions
Copy link

github-actions bot commented Jul 9, 2022

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 are likely to be ignored.

@1feres1
Copy link

1feres1 commented Jul 14, 2022

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

@github-actions
Copy link

github-actions bot commented Aug 7, 2022

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 are likely to be ignored.

@Moshekwa
Copy link

I'm also getting the same issue now :(

@Moshekwa
Copy link

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

@1feres1
Copy link

1feres1 commented Nov 22, 2022

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

@AgrawalAakashh0523
Copy link

Hello, I am still getting the same error :(

@shinem1199
Copy link

Hello, Yes still getting the same error. Downgrading requests did not work

@evanmcfarland
Copy link

I'm also struggling with this error.

@alexsomoza
Copy link
Author

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 !!!!!

@shinem1199
Copy link

@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
Readtimeout2-HuggingFace

@Luoyang144
Copy link

It works, thank you!

@edmondja
Copy link

Thanks it works if you do not forget to downgrade requests to 2.27.1 !!!

@1264561652
Copy link

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

@joisonwk
Copy link

你的问题解决了吗?怎么解决的?
代码里加两行就好了
import os
os.environ['CURL_CA_BUNDLE'] = ''

@xzc-Eureka
Copy link

Meet the same question.. Adding the 2 line code below seams bloking in downloading model

@SunHaozhe
Copy link
Contributor

SunHaozhe commented May 4, 2023

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

@cjl99
Copy link

cjl99 commented May 8, 2023

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

@fortunechen
Copy link

same issue here, + 2line and downgrade requests not work

@tvaranka
Copy link

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

@zazke
Copy link

zazke commented May 18, 2023

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

@tvaranka
Copy link

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.

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

@danyow-cheung
Copy link

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.

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

inflaton pushed a commit to inflaton/confidential-chatbot that referenced this issue Jun 1, 2023
@hoonlight
Copy link

same issue

@ShoupingShan
Copy link

same issue in python 3.7

@ShashwatNigam99
Copy link

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.

@mhoffmann1
Copy link

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.

@joisonwk
Copy link

same issue in python 3.9.0

@1327476339
Copy link

code add:
import os
os.environ['HTTP_PROXY'] = "http://192.168.xxx.xx:port"
os.environ['HTTPS_PROXY'] = "http://192.168.xxx.xx:port"

xxx:port is you proxy address

@ketaiq
Copy link

ketaiq commented Mar 22, 2024

For anyone who uses v2ray as a proxy tool, you should do following steps:

  1. Set up socks proxy on the port 1080 and http proxy on the port 1081 using the config.json file of v2ray.
  2. Add the argument proxies={"https": "http://127.0.0.1:1081", "http": "socks5://127.0.0.1:1080"} to the place you call the function hf_hub_download or any similar function for downloading models.

@Melmaphother
Copy link

don't set proxy in from_pretrained(), set it in environ: import os os.environ['CURL_CA_BUNDLE'] = '' os.environ['HTTP_PROXY'] = "http://127.0.0.1:7890" os.environ['HTTPS_PROXY'] = "http://127.0.0.1:7890" os.environ['ALL_PROXY'] = "socks5://127.0.0.1:7890"

jupyter notebook, python=3.8, urllib3=2.1.0, nice to me. But I use clash verge rev, so the proxy_port is 7897, not 7890. Be care to modify it!

@tigerxu
Copy link

tigerxu commented Apr 1, 2024

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 !!!!!

This works

Also works for me!

@xiaozhen228
Copy link

import os
os.environ['HF_ENDPOINT']= 'https://hf-mirror.com'

@Muqi1029
Copy link

Muqi1029 commented Apr 12, 2024

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

This works for me, you can also set the corresponding environment variables like this:

Set https_proxy

os.environ['https_proxy'] = 'http://127.0.0.1:10809'

Set http_proxy

os.environ['http_proxy'] = 'http://127.0.0.1:10809'

Set all_proxy

os.environ['all_proxy'] = 'socks5://127.0.0.1:10808'

@marouahamdi
Copy link

I have proxy restrictions in the company. Therefore, when I try to work with PrivateGPT (even though I have already downloaded the LLM model locally but not the embedder's), I get this error:

requests.exceptions.ProxyError: (MaxRetryError("HTTPSConnectionPool(host='huggingface.co', port=443): Max retries exceeded with url: /mistralai/Mistral-7B-Instruct-v0.2/resolve/main/tokenizer_config.json (Caused by ProxyError('Cannot connect to proxy.', OSError('Tunnel connection failed: 403 Forbidden')))"), '(Request ID: daac27c7-b24f-4c19-a707-895d5061595f)')"

@hughesadam87
Copy link

hughesadam87 commented Apr 19, 2024

Workaround: I Gave Up and Download All the Models Myself

Since Huggingface is silent on this issue, despite it being posted on stack overflow numerous times, as well as having dedicated blog posts, all of which provide answers that no longer work or are challenging to do in an enterprise environment, I've resided myself to just downloading the models on my laptop. In case useful:

  1. Choose a model, like this small one facebook/opt-125m

  2. Download each file and put them in a folder like /path/to/facebook/opt-125m
    image

  3. When running libraries such as transformers, which take a model parameter (eg. --model facebook/opt-125m), simply replace it with the full path on your machine (eg. --model /path/to/facebook/opt-125m),

Docker

If doing this in docker, you need to copy the model into the Dockerfile

 COPY /path/to/models   /mnt/models

and then just reference it like docker run ... --model /mnt/models/facebook/opt-125m

Alternatively, you can mount a volume so that docker can access the model on the host machine disk. Here is a docker-compose file that I use to do for an app:

image

version: '3.8'

services:
  local:
    build: .
    command: --model /mnt/models/facebook/opt-125m
    volumes:
      - ./models:/mnt/models
    ports:
      - "8000:8000"

Ignore the entrypoint which is specific to our application/use-case.

@marouahamdi
Copy link

thank you so much for the time and the answer. i have dowloaded locally the llm model, and normally i have the bge model in the cache folder of the proeject. for the tokenizer I don't know.. but in the setup of the project I have connexions to HF

@Ramboom
Copy link

Ramboom commented Apr 24, 2024

1、Setting up a proxy:
import os
os.environ["HTTP_PROXY"] = "127.0.0.1:7890"
os.environ["HTTPS_PROXY"] = "127.0.0.1:7890"
2、Adding specific host entries:
185.199.108.133 raw.githubusercontent.com
185.199.109.133 raw.githubusercontent.com
185.199.110.133 raw.githubusercontent.com
185.199.111.133 raw.githubusercontent.com
2606:50c0:8000::154 raw.githubusercontent.com
2606:50c0:8001::154 raw.githubusercontent.com
2606:50c0:8002::154 raw.githubusercontent.com
2606:50c0:8003::154 raw.githubusercontent.com

@wzhhaohao
Copy link

wzhhaohao commented Jun 13, 2024

for this issue, i tried several method:
1:downgrading requests==2.27.1 (i think it isn't the point)
2:import os
os.environ["HTTPS_PROXY"] = "https://127.0.0.1:23457" (it's the key to solve this prob)

direcet access to internet is limited, it seems like setting the HTTPS_PROXY environment variable was the key to resolving SSL/TLS connection issue.

@panpan123456
Copy link

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'

Thanks, this save my day。 I am at china, every thing went well after setting proxy manually, even though I had my vpn openned globally.

hi, how to get http://proxy.company.com:port number,I am in china ,too

@chunhualiao
Copy link

I also have the same error. We are behind some firewall.

requests.exceptions.SSLError: (MaxRetryError("HTTPSConnectionPool(host='huggingface.co', port=443): Max retries exceeded with url: /nomic-ai/nomic-embed-text-v1/resolve/main/config.json (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1007)')))"), '(Request ID: ab5e7aff-b624-416b-b3ee-72f4922264f3)')

Can we just allow users to easily bypass this verification step?

@MexWayne
Copy link

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

you are genius, thanks god! 老铁666, 流逼了

@liduang
Copy link

liduang commented Jul 17, 2024

如果配置了代理还是不行,一定date下看看时间对不对,我是日特么的时区不对,时间超前了,所以一致ssl错误

@lizhaohu
Copy link

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

import os os.environ['HF_ENDPOINT']= 'https://hf-mirror.com'

great it work for me!!!!!!!

@chuanhello
Copy link

There could be many reasons why you're seeing 443 port and SSL errors. A possible solution is to add the certificate from 'https://huggingface.co/' to your trusted root certificates.

@BlueCat-de
Copy link

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

Thanks a lot !!!

@zejun-chen
Copy link

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

Thanks a lot !!!

Does it work for now? It seems not work for me.

@CSU-OSS
Copy link

CSU-OSS commented Oct 3, 2024

I had the same problem. I solved this by changing this:

# new
import os
os.environ['HF_ENDPOINT'] = 'https://hf-mirror.com'

->

# old
import os
os.environ['HUGGINGFACE_CO_RESOLVE_ENDPOINT'] = 'https://hf-mirror.com'

@Amber1900
Copy link

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

This works for me, you can also set the corresponding environment variables like this:

Set https_proxy

os.environ['https_proxy'] = 'http://127.0.0.1:10809'

Set http_proxy

os.environ['http_proxy'] = 'http://127.0.0.1:10809'

Set all_proxy

os.environ['all_proxy'] = 'socks5://127.0.0.1:10808'

it works
openvoice

@Moprst
Copy link

Moprst commented Oct 22, 2024

Try adding this snippet to the code, it worked for me
import os
os.environ['HTTP_PROXY'] = "http://127.0.0.1:Port"
os.environ['HTTPS_PROXY'] = "http://127.0.0.1:Port"
Port represents the port used by the proxy tool

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests