Huggingface-cli login hangs
Has anyone run into very slow connection speeds with huggingface-cli login? I’m also having issues with other things like loading datasets. I’m including the stacktrace when I cancel the login because it hangs forever. The same behavior happens when I’m callingload_dataset.✗ huggingface-cli env  

Copy-and-paste the text below in your GitHub issue.

- huggingface_hub version: 0.16.4
- Platform: Linux-6.2.0-26-generic-x86_64-with-glibc2.35
- Python version: 3.10.12
- Running in iPython ?: No
- Running in notebook ?: No
- Running in Google Colab ?: No
- Token path ?: /home/kyle/.cache/huggingface/token
- Has saved token ?: False
- Configured git credential helpers: store
- FastAI: N/A
- Tensorflow: N/A
- Torch: 2.0.1
- Jinja2: 3.1.2
- Graphviz: N/A
- Pydot: N/A
- Pillow: N/A
- REDACTED_TOKEN: N/A
- gradio: N/A
- tensorboard: N/A
- numpy: 1.25.2
- pydantic: N/A
- aiohttp: 3.8.5
- ENDPOINT: https://huggingface.co
- HUGGINGFACE_HUB_CACHE: /home/kyle/.cache/huggingface/hub
- HUGGINGFACE_ASSETS_CACHE: /home/kyle/.cache/huggingface/assets
- HF_TOKEN_PATH: /home/kyle/.cache/huggingface/token
- HF_HUB_OFFLINE: False
- HF_HUB_DISABLE_TELEMETRY: False
- HF_HUB_DISABLE_PROGRESS_BARS: None
- HF_HUB_DISABLE_SYMLINKS_WARNING: False
- HF_HUB_DISABLE_EXPERIMENTAL_WARNING: False
- HF_HUB_DISABLE_IMPLICIT_TOKEN: False
- HF_HUB_ENABLE_HF_TRANSFER: False✗ huggingface-cli login

   _|    _|  _|    _|    _|_|_|    _|_|_|  _|_|_|  _|      _|    _|_|_|      _|_|_|_|    _|_|      _|_|_|  _|_|_|_|
   _|    _|  _|    _|  _|        _|          _|    _|_|    _|  _|            _|        _|    _|  _|        _|
   _|_|_|_|  _|    _|  _|  _|_|  _|  _|_|    _|    _|  _|  _|  _|  _|_|      _|_|_|    _|_|_|_|  _|        _|_|_|
   _|    _|  _|    _|  _|    _|  _|    _|    _|    _|    _|_|  _|    _|      _|        _|    _|  _|        _|
   _|    _|    _|_|      _|_|_|    _|_|_|  _|_|_|  _|      _|    _|_|_|      _|        _|    _|    _|_|_|  _|_|_|_|
   
   To login, `huggingface_hub` requires a token generated from https://huggingface.co/settings/tokens .
Token: 
Add token as git credential? (Y/n) n
^CTraceback (most recent call last):
 File "/home/kyle/miniconda3/envs/huggingface/bin/huggingface-cli", line 8, in <module>
   sys.exit(main())
 File "/home/kyle/miniconda3/envs/huggingface/lib/python3.10/site-packages/huggingface_hub/commands/huggingface_cli.py", line 45, in main
   service.run()
 File "/home/kyle/miniconda3/envs/huggingface/lib/python3.10/site-packages/huggingface_hub/commands/user.py", line 101, in run
   login(token=self.args.token, add_to_git_credential=self.args.add_to_git_credential)
 File "/home/kyle/miniconda3/envs/huggingface/lib/python3.10/site-packages/huggingface_hub/_login.py", line 100, in login
   interpreter_login(new_session=new_session, write_permission=write_permission)
 File "/home/kyle/miniconda3/envs/huggingface/lib/python3.10/site-packages/huggingface_hub/_login.py", line 164, in interpreter_login
   _login(token=token, add_to_git_credential=add_to_git_credential, write_permission=write_permission)
 File "/home/kyle/miniconda3/envs/huggingface/lib/python3.10/site-packages/huggingface_hub/_login.py", line 273, in _login
   permission = get_token_permission(token)
 File "/home/kyle/miniconda3/envs/huggingface/lib/python3.10/site-packages/huggingface_hub/REDACTED_TOKEN.py", line 958, in get_token_permission
   return self.whoami(token=token)["auth"]["accessToken"]["role"]
 File "/home/kyle/miniconda3/envs/huggingface/lib/python3.10/site-packages/huggingface_hub/utils/_validators.py", line 118, in _inner_fn
   return fn(*args, **kwargs)
 File "/home/kyle/miniconda3/envs/huggingface/lib/python3.10/site-packages/huggingface_hub/REDACTED_TOKEN.py", line 925, in whoami
   r = get_session().get(
 File "/home/kyle/miniconda3/envs/huggingface/lib/python3.10/site-packages/requests/sessions.py", line 602, in get
   return self.request("GET", url, **kwargs)
 File "/home/kyle/miniconda3/envs/huggingface/lib/python3.10/site-packages/requests/sessions.py", line 589, in request
   resp = self.send(prep, **send_kwargs)
 File "/home/kyle/miniconda3/envs/huggingface/lib/python3.10/site-packages/requests/sessions.py", line 703, in send
   r = adapter.send(request, **kwargs)
 File "/home/kyle/miniconda3/envs/huggingface/lib/python3.10/site-packages/huggingface_hub/utils/_http.py", line 63, in send
   return super().send(request, *args, **kwargs)
 File "/home/kyle/miniconda3/envs/huggingface/lib/python3.10/site-packages/requests/adapters.py", line 486, in send
   resp = conn.urlopen(
 File "/home/kyle/miniconda3/envs/huggingface/lib/python3.10/site-packages/urllib3/connectionpool.py", line 790, in urlopen
   response = self._make_request(
 File "/home/kyle/miniconda3/envs/huggingface/lib/python3.10/site-packages/urllib3/connectionpool.py", line 467, in _make_request
   self._validate_conn(conn)
 File "/home/kyle/miniconda3/envs/huggingface/lib/python3.10/site-packages/urllib3/connectionpool.py", line 1092, in _validate_conn
   conn.connect()
 File "/home/kyle/miniconda3/envs/huggingface/lib/python3.10/site-packages/urllib3/connection.py", line 611, in connect
   self.sock = sock = self._new_conn()
 File "/home/kyle/miniconda3/envs/huggingface/lib/python3.10/site-packages/urllib3/connection.py", line 203, in _new_conn
   sock = connection.create_connection(
 File "/home/kyle/miniconda3/envs/huggingface/lib/python3.10/site-packages/urllib3/util/connection.py", line 73, in create_connection
   sock.connect(sa)
KeyboardInterrupt
2023-08-26T20:56:08Z
This is working, so my internet speed and my HUGGINGFACE_TOKEN are just fine.import os
import requests

def query(payload, model_id, api_token):
	headers = {"Authorization": f"Bearer {api_token}"}
	API_URL = f"https://api-inference.huggingface.co/models/{model_id}"
	response = requests.post(API_URL, headers=headers, json=payload)
	return response.json()

model_id = "distilbert-base-uncased"
api_token = os.environ["HUGGINGFACE_TOKEN"]
data = query("The goal of life is [MASK].", model_id, api_token)
print(data)[{'score': 0.03619178757071495, 'token': 8404, 'token_str': 'happiness', 'sequence': 'the goal of life is happiness.'}, {'score': 0.030553586781024933, 'token': 7691, 'token_str': 'survival', 'sequence': 'the goal of life is survival.'}, {'score': 0.01697724126279354, 'token': 12611, 'token_str': 'salvation', 'sequence': 'the goal of life is salvation.'}, {'score': 0.01669846847653389, 'token': 4071, 'token_str': 'freedom', 'sequence': 'the goal of life is freedom.'}, {'score': 0.0152673264965415, 'token': 8499, 'token_str': 'unity', 'sequence': 'the goal of life is unity.'}]But this will hang foreverfrom datasets import load_dataset

raw_datasets = load_dataset("glue", "mrpc")
2023-08-26T21:12:53Z
Oh, I just found the issue and the fix✗ sudo sysctl -w net.ipv6.conf.all.disable_ipv6=1
sudo sysctl -w net.ipv6.conf.default.disable_ipv6=1
[sudo] password for kyle: 
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
✗ huggingface-cli login                          

    _|    _|  _|    _|    _|_|_|    _|_|_|  _|_|_|  _|      _|    _|_|_|      _|_|_|_|    _|_|      _|_|_|  _|_|_|_|
    _|    _|  _|    _|  _|        _|          _|    _|_|    _|  _|            _|        _|    _|  _|        _|
    _|_|_|_|  _|    _|  _|  _|_|  _|  _|_|    _|    _|  _|  _|  _|  _|_|      _|_|_|    _|_|_|_|  _|        _|_|_|
    _|    _|  _|    _|  _|    _|  _|    _|    _|    _|    _|_|  _|    _|      _|        _|    _|  _|        _|
    _|    _|    _|_|      _|_|_|    _|_|_|  _|_|_|  _|      _|    _|_|_|      _|        _|    _|    _|_|_|  _|_|_|_|
    
    To login, `huggingface_hub` requires a token generated from https://huggingface.co/settings/tokens .
Token: 
Add token as git credential? (Y/n) n
Token is valid (permission: write).
Your token has been saved to /home/kyle/.cache/huggingface/token
Login successful
2024-07-08T02:56:54Z
I have added the following code and it worksexport 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