# Huggingface-cli login hangs

**URL:** <https://discuss.huggingface.co/t/huggingface-cli-login-hangs/52298>\
**Category:** Beginners\
**Created:** [August 26, 2023, 8:52pm UTC](https://discuss.huggingface.co/t/huggingface-cli-login-hangs/52298 "2023-08-26T20:52:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![kmadsen](https://avatars.discourse-cdn.com/v4/letter/k/b2d939/32.png) [@kmadsen](https://discuss.huggingface.co/u/kmadsen)\
**Post date:** [August 26, 2023, 8:52pm UTC](https://discuss.huggingface.co/t/huggingface-cli-login-hangs/52298/1 "2023-08-26T20:52:00Z")

</div>

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 calling `load_dataset`.

```auto
✗ 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
- hf_transfer: 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

```

```auto
✗ 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/hf_api.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/hf_api.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

```

---

<div class="post-metadata">

**Author:** ![kmadsen](https://avatars.discourse-cdn.com/v4/letter/k/b2d939/32.png) [@kmadsen](https://discuss.huggingface.co/u/kmadsen)\
**Post date:** [August 26, 2023, 8:56pm UTC](https://discuss.huggingface.co/t/huggingface-cli-login-hangs/52298/2 "2023-08-26T20:56:08Z")

</div>

This is working, so my internet speed and my HUGGINGFACE\_TOKEN are just fine.

```python
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)

```

```plaintext
[{'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 forever

```auto
from datasets import load_dataset

raw_datasets = load_dataset("glue", "mrpc")

```

---

<div class="post-metadata">

**Author:** ![kmadsen](https://avatars.discourse-cdn.com/v4/letter/k/b2d939/32.png) [@kmadsen](https://discuss.huggingface.co/u/kmadsen)\
**Post date:** [August 26, 2023, 9:12pm UTC](https://discuss.huggingface.co/t/huggingface-cli-login-hangs/52298/3 "2023-08-26T21:12:53Z")

</div>

Oh, I just found the issue and the fix

```auto
✗ 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

```

---

<div class="post-metadata">

**Author:** ![Shiki0619](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/shiki0619/32/29098_2.png) [@Shiki0619](https://discuss.huggingface.co/u/Shiki0619)\
**Post date:** [July 8, 2024, 2:56am UTC](https://discuss.huggingface.co/t/huggingface-cli-login-hangs/52298/4 "2024-07-08T02:56:54Z")

</div>

I have added the following code and it works

```auto
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

```
