# Can't login to Huggingface CLI

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fcant-login-to-huggingface-cli%2F139741%3E%5C
**Category:** Beginners\
**Created:** [February 8, 2025, 6:18pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fcant-login-to-huggingface-cli%2F139741 "2025-02-08T18:18:54Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![nishadsinghi](https://avatars.discourse-cdn.com/v4/letter/n/46a35a/32.png) [@nishadsinghi](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fnishadsinghi)%5C
**Post date:** [February 8, 2025, 6:18pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fcant-login-to-huggingface-cli%2F139741%2F1 "2025-02-08T18:18:55Z")

</div>

I am trying to login to huggingface-cli using:

```auto
huggingface-cli login

```

and keep getting this error:

```auto
Traceback (most recent call last):
  File "/pfss/mlde/workspaces/mlde_wsp_Rohrbach/users/ns94feza/.conda/envs/llmonk2/bin/huggingface-cli", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/pfss/mlde/workspaces/mlde_wsp_Rohrbach/users/ns94feza/.conda/envs/llmonk2/lib/python3.11/site-packages/huggingface_hub/commands/huggingface_cli.py", line 57, in main
    service.run()
  File "/pfss/mlde/workspaces/mlde_wsp_Rohrbach/users/ns94feza/.conda/envs/llmonk2/lib/python3.11/site-packages/huggingface_hub/commands/user.py", line 98, in run
    login(token=self.args.token, add_to_git_credential=self.args.add_to_git_credential)
  File "/pfss/mlde/workspaces/mlde_wsp_Rohrbach/users/ns94feza/.conda/envs/llmonk2/lib/python3.11/site-packages/huggingface_hub/_login.py", line 115, in login
    interpreter_login(new_session=new_session, write_permission=write_permission)
  File "/pfss/mlde/workspaces/mlde_wsp_Rohrbach/users/ns94feza/.conda/envs/llmonk2/lib/python3.11/site-packages/huggingface_hub/_login.py", line 194, in interpreter_login
    _login(token=token, add_to_git_credential=add_to_git_credential, write_permission=write_permission)
  File "/pfss/mlde/workspaces/mlde_wsp_Rohrbach/users/ns94feza/.conda/envs/llmonk2/lib/python3.11/site-packages/huggingface_hub/_login.py", line 307, in _login
    raise ValueError("Invalid token passed!")
ValueError: Invalid token passed!

```

I have tried pasting via a right-click instead of cmd+v but that didn’t work. This token has worked in the past, and I have tried using a fresh token as well, but nothing has worked so far.

For context, I recently got rate limited while trying to upload some data, so I’m wondering if that caused this issue. Is there a way to lift the limit? it’s been a few hours since it was applied.

@Wauplin I was wondering if you could somehow help here

---

<div class="post-metadata">

**Author:** ![nnilayy](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/nnilayy/32/39238_2.png) [@nnilayy](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fnnilayy)%5C
**Post date:** [February 8, 2025, 8:09pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fcant-login-to-huggingface-cli%2F139741%2F2 "2025-02-08T20:09:10Z")

</div>

Hey @nishadsinghi,  
Can you maybe try logging in by passing the token directly as a flag in the terminal:

```bash
huggingface-cli login --token hf_yourtoken

```

If this doesn’t resolve the issue, you can try some other discussed solutions in a similar discussion in (@ [How to login to Huggingface Hub with Access Token](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-login-to-huggingface-hub-with-access-token%2F22498)). Let me know if this helps! If the issue persists, feel free to update here.

---

<div class="post-metadata">

**Author:** ![nishadsinghi](https://avatars.discourse-cdn.com/v4/letter/n/46a35a/32.png) [@nishadsinghi](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fnishadsinghi)%5C
**Post date:** [February 9, 2025, 4:00am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fcant-login-to-huggingface-cli%2F139741%2F3 "2025-02-09T04:00:49Z")

</div>

Hi @nnilayy, thanks for replying!

1. I tried huggingface-cli login --token my\_token and got the same error.
2. I tried the tips from the link you shared (like pasting the token using the mouse instead of cmd+v) and that doesn’t work either.  
Let me know if you have any other suggestions!

---

<div class="post-metadata">

**Author:** ![John6666](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/john6666/32/27664_2.png) [@John6666](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FJohn6666)%5C
**Post date:** [February 9, 2025, 4:12am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fcant-login-to-huggingface-cli%2F139741%2F4 "2025-02-09T04:12:56Z")

</div>

It seems that there are also cases where the cause is something else.

> [@Invalid token passed?](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Finvalid-token-passed%2F22711%3Fpage%3D2)%3A
>
> Token: Traceback (most recent call last): File “C:\Users\paint\anaconda3\Scripts\huggingface-cli-script.py”, line 9, in sys.exit(main()) File “C:\Users\paint\anaconda3\lib\site-packages\huggingface\_hub\commands\huggingface\_cli.py”, line 41, in main service.run() File “C:\Users\paint\anaconda3\lib\site-packages\huggingface\_hub\commands\user.py”, line 176, in run \_login(self.\_api, token=token) File “C:\Users\paint\anaconda3\lib\site-packages\huggingface\_hub\commands\user.py”, line 343, i…

---

<div class="post-metadata">

**Author:** ![nishadsinghi](https://avatars.discourse-cdn.com/v4/letter/n/46a35a/32.png) [@nishadsinghi](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fnishadsinghi)%5C
**Post date:** [February 9, 2025, 4:34am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fcant-login-to-huggingface-cli%2F139741%2F5 "2025-02-09T04:34:22Z")

</div>

Hey @John6666, thanks for your reply 🙂 Like I said, I’ve already tried alternative ways of pasting the token, but so far nothing has worked.

---

<div class="post-metadata">

**Author:** ![John6666](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/john6666/32/27664_2.png) [@John6666](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FJohn6666)%5C
**Post date:** [February 9, 2025, 4:38am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fcant-login-to-huggingface-cli%2F139741%2F6 "2025-02-09T04:38:28Z")

</div>

It’s not just because of the token, but it seems to happen for other reasons too, such as an old version of **git itself** … As a result, it cannot interpret the tokens.  
This happens particularly on Windows.

---

<div class="post-metadata">

**Author:** ![nnilayy](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/nnilayy/32/39238_2.png) [@nnilayy](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fnnilayy)%5C
**Post date:** [February 9, 2025, 11:07am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fcant-login-to-huggingface-cli%2F139741%2F7 "2025-02-09T11:07:04Z")

</div>

Hey @nishadsinghi,  
Another workaround that seems to work on my end is using a notebook to log in within the same environment where `huggingface_hub[cli]` is installed. You can try running the following in a `.ipynb` notebook and paste your token into the displayed textbox:

```python
from huggingface_hub import login
login()

```

After entering your token, check if you’re successfully logged in by running the following in a terminal:

```bash
huggingface-cli whoami  

```

If it displays your Hugging Face username, the login was successful.

Additionally, as @John6666 pointed out, outdated versions of Git can also lead to silent issues. You can check your Git version with:

```auto
git --version

```

If it’s an older version, updating it might help. You can update Git using:

```bash
git update

```

After this, try logging in again using the different methods discussed earlier. Let us know if it works or if you’re still facing issues!

---

<div class="post-metadata">

**Author:** ![nishadsinghi](https://avatars.discourse-cdn.com/v4/letter/n/46a35a/32.png) [@nishadsinghi](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fnishadsinghi)%5C
**Post date:** [February 9, 2025, 2:36pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fcant-login-to-huggingface-cli%2F139741%2F8 "2025-02-09T14:36:53Z")

</div>

Hi @nnilayy, thanks for the suggestions. I tried logging in through a notebook but still got the same error.  
I am using this on a cluster, and I think updating git requires sudo access, so I couldn’t do it. I have a feeling that this is not the root cause of the issue, since things were working fine until recently (but I could be wrong).

---

<div class="post-metadata">

**Author:** ![John6666](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/john6666/32/27664_2.png) [@John6666](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FJohn6666)%5C
**Post date:** [February 9, 2025, 3:00pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fcant-login-to-huggingface-cli%2F139741%2F9 "2025-02-09T15:00:41Z")

</div>

Maybe cluster is suspicious. But for example, there are often cases where authentication fails due to SSL settings, but in that case, the error message shouldn’t be that…  
So I’m confused.

---

<div class="post-metadata">

**Author:** ![nishadsinghi](https://avatars.discourse-cdn.com/v4/letter/n/46a35a/32.png) [@nishadsinghi](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fnishadsinghi)%5C
**Post date:** [February 9, 2025, 4:05pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fcant-login-to-huggingface-cli%2F139741%2F10 "2025-02-09T16:05:27Z")

</div>

Is there a way to check the rate limits? I’ve contacted HF via email but haven’t heard back 😕

---

<div class="post-metadata">

**Author:** ![Wauplin](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/wauplin/32/40815_2.png) [@Wauplin](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FWauplin)%5C
**Post date:** [February 10, 2025, 11:41am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fcant-login-to-huggingface-cli%2F139741%2F11 "2025-02-10T11:41:32Z")

</div>

Hi @nishadsinghi sorry for the inconvenience. Could you try to login using a script just to be 100% sure it’s not a encoding issue with the terminal:

```py
from huggingface_hub import login, whoami

login(token="hf_....")
whoami()

```

Also, could you install `huggingface_hub` from source (see [install steps](https://huggingface.co/docs/huggingface_hub/installation#install-from-source)) and retry? We’ve recently pushed a small feature that tells you which token has been used when `whoami` fails. Sometimes it can be due to an environement vairable (`HF_TOKEN`) mixing with the locally saved one.

* * *

**Note:** `huggingface_hub`/`huggingface-cli` are only using HTTP calls and are completely separated from `git`. There is nothing you can do on the git side that breaks huggingface-cli (and therefore nothing you can do to fix it using git)

---

<div class="post-metadata">

**Author:** ![nishadsinghi](https://avatars.discourse-cdn.com/v4/letter/n/46a35a/32.png) [@nishadsinghi](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fnishadsinghi)%5C
**Post date:** [February 10, 2025, 6:55pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fcant-login-to-huggingface-cli%2F139741%2F12 "2025-02-10T18:55:44Z")

</div>

> [@Wauplin](#):
>
> ```auto
> login(token="hf_....")
> 
> ```

Hey @Wauplin, thanks for getting back to me. I followed these steps:

1. Created a fresh conda environment, and installed HF hub from source using:

```auto
pip install git+https://github.com/huggingface/huggingface_hub

```

1. Created a script with the contents you posted.
2. Ran the python script from step 2.

And I still get the same ‘Invalid token’ error.  
Just for context, I am doing all of this on a remote cluster.  
I also tried to login on my local machine using the same token and that works, so the token is not the issue.

---

<div class="post-metadata">

**Author:** ![samarthdave0305](https://avatars.discourse-cdn.com/v4/letter/s/8797f3/32.png) [@samarthdave0305](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fsamarthdave0305)%5C
**Post date:** [April 4, 2026, 12:50pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fcant-login-to-huggingface-cli%2F139741%2F13 "2026-04-04T12:50:25Z")

</div>

So what ended up working for me was instead of using Ctrl+V to paste the access token I right-clicked on the command line and it pasted it. Note that you still won’t see anything on the ‘Token:’ line but it is should be there. Hope this helps!!
