# Error 401 Client Error: Unauthorized for url

**URL:** <https://discuss.huggingface.co/t/error-401-client-error-unauthorized-for-url/19714>\
**Category:** 🤗Hub\
**Created:** [June 28, 2022, 8:17am UTC](https://discuss.huggingface.co/t/error-401-client-error-unauthorized-for-url/19714 "2022-06-28T08:17:42Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![talids](https://avatars.discourse-cdn.com/v4/letter/t/848f3c/32.png) [@talids](https://discuss.huggingface.co/u/talids)\
**Post date:** [June 28, 2022, 8:17am UTC](https://discuss.huggingface.co/t/error-401-client-error-unauthorized-for-url/19714/1 "2022-06-28T08:17:42Z")

</div>

When using model card of my private speech recognition model with LM, I got this error:

401 Client Error: Unauthorized for url: [https://huggingface.co/api/models/taliai/tali-asr-with-lm/revision/main](https://huggingface.co/api/models/taliai/tali-asr-with-lm/revision/main)

while the same model without lm works fine.

Is there anything wrong on my model or model card or …  
Any help is appreciated.

---

<div class="post-metadata">

**Author:** ![pierric](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/pierric/32/50750_2.png) [@pierric](https://discuss.huggingface.co/u/pierric)\
**Post date:** [June 28, 2022, 1:21pm UTC](https://discuss.huggingface.co/t/error-401-client-error-unauthorized-for-url/19714/2 "2022-06-28T13:21:43Z")

</div>

Hi @talids, you’re getting a 401 error because you’re not authenticated when making the request, and either:

- the model doesn’t exist
- the model is private

From your message, I get that you’re in the second situation. Please make sure that you’re authenticated when calling the API. You’ll need a [personal access token](https://hf.co/settings/tokens) to do so, which you can then pass in the `Authorization` header of your request in the form `Bearer <TOKEN>`.

---

<div class="post-metadata">

**Author:** ![talids](https://avatars.discourse-cdn.com/v4/letter/t/848f3c/32.png) [@talids](https://discuss.huggingface.co/u/talids)\
**Post date:** [June 29, 2022, 7:26am UTC](https://discuss.huggingface.co/t/error-401-client-error-unauthorized-for-url/19714/3 "2022-06-29T07:26:34Z")

</div>

Thanks @pierric,  
Actually, my model is private, but I logged in already, and access token is also correct. I checked them many times, even I generated new access tokens, but the error message is the same.

---

<div class="post-metadata">

**Author:** ![pierric](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/pierric/32/50750_2.png) [@pierric](https://discuss.huggingface.co/u/pierric)\
**Post date:** [June 29, 2022, 1:02pm UTC](https://discuss.huggingface.co/t/error-401-client-error-unauthorized-for-url/19714/4 "2022-06-29T13:02:34Z")

</div>

Hi @talids,

When you say that you’re “logged in already”, what do you mean exactly? Do you mean that you’re logged-in in your browser on [hf.co](http://hf.co)?

What do you use to make your call to [https://huggingface.co/api/models/taliai/tali-asr-with-lm/revision/main](https://huggingface.co/api/models/taliai/tali-asr-with-lm/revision/main)? Do you use a python lib?

---

<div class="post-metadata">

**Author:** ![pierric](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/pierric/32/50750_2.png) [@pierric](https://discuss.huggingface.co/u/pierric)\
**Post date:** [June 29, 2022, 1:04pm UTC](https://discuss.huggingface.co/t/error-401-client-error-unauthorized-for-url/19714/5 "2022-06-29T13:04:29Z")

</div>

I see that you also emailed support, let’s keep the discussion here if possible @talids, as it could be useful for others.

---

<div class="post-metadata">

**Author:** ![talids](https://avatars.discourse-cdn.com/v4/letter/t/848f3c/32.png) [@talids](https://discuss.huggingface.co/u/talids)\
**Post date:** [June 29, 2022, 2:16pm UTC](https://discuss.huggingface.co/t/error-401-client-error-unauthorized-for-url/19714/6 "2022-06-29T14:16:53Z")

</div>

Sure!  
Here is a bit more detail.  
This is the error we are getting  
And this is the case for this specific model.  
our other ASR model which is not `withLM` is working fine.

 ![Screen Shot 2022-06-29 at 6.40.05 PM](https://us1.discourse-cdn.com/hellohellohello/original/2X/d/d4542b9be9ef267cffb8acdbc00ffa65c6b48379.png)

---

<div class="post-metadata">

**Author:** ![pierric](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/pierric/32/50750_2.png) [@pierric](https://discuss.huggingface.co/u/pierric)\
**Post date:** [June 29, 2022, 3:29pm UTC](https://discuss.huggingface.co/t/error-401-client-error-unauthorized-for-url/19714/7 "2022-06-29T15:29:54Z")

</div>

Thanks for those additional details, the team is going to investigate more and we’ll come back to you.

---

<div class="post-metadata">

**Author:** ![talids](https://avatars.discourse-cdn.com/v4/letter/t/848f3c/32.png) [@talids](https://discuss.huggingface.co/u/talids)\
**Post date:** [June 29, 2022, 4:09pm UTC](https://discuss.huggingface.co/t/error-401-client-error-unauthorized-for-url/19714/8 "2022-06-29T16:09:46Z")

</div>

Awesome. Plz let me know if we can provide anymore info to help pinpoint the issue faster.

---

<div class="post-metadata">

**Author:** ![talids](https://avatars.discourse-cdn.com/v4/letter/t/848f3c/32.png) [@talids](https://discuss.huggingface.co/u/talids)\
**Post date:** [June 29, 2022, 7:33pm UTC](https://discuss.huggingface.co/t/error-401-client-error-unauthorized-for-url/19714/9 "2022-06-29T19:33:22Z")

</div>

The problem seems to be resolved. Did you guys did something on your end?

---

<div class="post-metadata">

**Author:** ![pierric](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/pierric/32/50750_2.png) [@pierric](https://discuss.huggingface.co/u/pierric)\
**Post date:** [July 5, 2022, 3:55pm UTC](https://discuss.huggingface.co/t/error-401-client-error-unauthorized-for-url/19714/10 "2022-07-05T15:55:57Z")

</div>

@talids we didn’t change anything directly related, AFAIK. Can you confirm that it’s still working for you?

---

<div class="post-metadata">

**Author:** ![israel](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/israel/32/23046_2.png) [@israel](https://discuss.huggingface.co/u/israel)\
**Post date:** [October 20, 2022, 1:01am UTC](https://discuss.huggingface.co/t/error-401-client-error-unauthorized-for-url/19714/11 "2022-10-20T01:01:59Z")

</div>

Having this @talids@pierric any idea what the solution or the problem is.

---

<div class="post-metadata">

**Author:** ![pierric](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/pierric/32/50750_2.png) [@pierric](https://discuss.huggingface.co/u/pierric)\
**Post date:** [October 20, 2022, 7:18pm UTC](https://discuss.huggingface.co/t/error-401-client-error-unauthorized-for-url/19714/12 "2022-10-20T19:18:40Z")

</div>

@israel can you give more details?

- is it happening when you’re trying to use the inference widget? if not, what specific HTTP call are you making?
- what model/repo are you talking about?

---

<div class="post-metadata">

**Author:** ![tsei902](https://avatars.discourse-cdn.com/v4/letter/t/5f9b8f/32.png) [@tsei902](https://discuss.huggingface.co/u/tsei902)\
**Post date:** [October 20, 2022, 7:22pm UTC](https://discuss.huggingface.co/t/error-401-client-error-unauthorized-for-url/19714/13 "2022-10-20T19:22:47Z")

</div>

@ pierric, same issue here.

The Model/repo in question: yhavinga/t5-base-dutch  
The error message: “Repository Not Found for url: [https://huggingface.co/api/repos/create](https://huggingface.co/api/repos/create).  
Please make sure you specified the correct `repo_id` and `repo_type`.  
If the repo is private, make sure you are authenticated.  
Unauthorized - Unauthorized”

I am logged in, it seems to make no difference if I do so with a read or write access token.

---

<div class="post-metadata">

**Author:** ![alikanakar](https://avatars.discourse-cdn.com/v4/letter/a/ed8c4c/32.png) [@alikanakar](https://discuss.huggingface.co/u/alikanakar)\
**Post date:** [October 20, 2022, 8:38pm UTC](https://discuss.huggingface.co/t/error-401-client-error-unauthorized-for-url/19714/14 "2022-10-20T20:38:55Z")

</div>

@tsei902 completely same issue here.

---

<div class="post-metadata">

**Author:** ![israel](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/israel/32/23046_2.png) [@israel](https://discuss.huggingface.co/u/israel)\
**Post date:** [October 24, 2022, 2:49pm UTC](https://discuss.huggingface.co/t/error-401-client-error-unauthorized-for-url/19714/15 "2022-10-24T14:49:57Z")

</div>

I found that my authentication key was not being used, that solved it.

---

<div class="post-metadata">

**Author:** ![OzzyD](https://avatars.discourse-cdn.com/v4/letter/o/919ad9/32.png) [@OzzyD](https://discuss.huggingface.co/u/OzzyD)\
**Post date:** [October 28, 2022, 9:58am UTC](https://discuss.huggingface.co/t/error-401-client-error-unauthorized-for-url/19714/16 "2022-10-28T09:58:09Z")

</div>

Hi everyone

I’m getting the same issue when trying to run the textural inversion example from the example script here: [Textual Inversion](https://huggingface.co/docs/diffusers/training/text_inversion)

Edit: the error specifically is “ **HTTPError:**  **401** Client Error: Unauthorized for url: [https://huggingface.co/CompVis/stable-diffusion-v1-4/resolve/main/tokenizer/vocab.json](https://huggingface.co/CompVis/stable-diffusion-v1-4/resolve/main/tokenizer/vocab.json)” followed by a hefty traceback

This happens with CompVis/stable-diffusion-v1-4 model and I’m “logged in” using huggingface-cli, so that whoami returns “OzzyD”.

Edit: Incidentally, I can open this file from the link in my browser, so it must be something to do with authenticating on the command line.

I’m having the feeling I’m not doing this correctly. Am I?

---

<div class="post-metadata">

**Author:** ![Wauplin](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/wauplin/32/40815_2.png) [@Wauplin](https://discuss.huggingface.co/u/Wauplin)\
**Post date:** [October 31, 2022, 5:03pm UTC](https://discuss.huggingface.co/t/error-401-client-error-unauthorized-for-url/19714/17 "2022-10-31T17:03:13Z")

</div>

Hi @OzzyD , have you accepted the license on [CompVis/stable-diffusion-v1-4 · Hugging Face](https://huggingface.co/CompVis/stable-diffusion-v1-4) page ? If yes, can you share which version of `huggingface_hub` you are using and the full traceback you are getting ?

We are making efforts to make error messages more explicit but gated repos are still not handled perfectly. Next version of `huggingface_hub` (to be released soon) should solve that.

---

<div class="post-metadata">

**Author:** ![OzzyD](https://avatars.discourse-cdn.com/v4/letter/o/919ad9/32.png) [@OzzyD](https://discuss.huggingface.co/u/OzzyD)\
**Post date:** [November 1, 2022, 11:08am UTC](https://discuss.huggingface.co/t/error-401-client-error-unauthorized-for-url/19714/18 "2022-11-01T11:08:41Z")

</div>

Hi @Wauplin. I have accepted the license on the v1-4 model page.

However, whilst checking for what version of huggingface\_hub I had installed, I decided to update my Python environment to the one suggested in the requirements.txt file for that repo, which I already thought it was. This appeared to fix my issue. My rookie mistake.

I look forward to the update to huggingface\_hub and thank you for your time 🙂

---

<div class="post-metadata">

**Author:** ![maveriq](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/maveriq/32/27075_2.png) [@maveriq](https://discuss.huggingface.co/u/maveriq)\
**Post date:** [December 7, 2022, 11:50pm UTC](https://discuss.huggingface.co/t/error-401-client-error-unauthorized-for-url/19714/19 "2022-12-07T23:50:01Z")

</div>

I am getting the same error for a private model (my own) on one machine, but I don’t get the error on another machine. I have checked the versions of transformers and huggingface\_hub and they are both same. I also tried with and without the ‘huggingface\_hub login’ and the error persists. The exact error I get is

> RepositoryNotFoundError: 401 Client Error: Repository not found for url: [https://huggingface.co/maveriq/mymodel/resolve/main/modelling\_mymodel.py](https://huggingface.co/maveriq/mymodel/resolve/main/modelling_mymodel.py). If the repo is private, make sure you are authenticated.

However as stated earlier in the thread, I can open the url.  
huggingface-hub 0.10.1  
transformers 4.24.0

Update : While I was posting this, I downgraded huggingface\_hub to 0.9.1 and transformers to 4.22.2, and it worked on the machine where earlier I was getting the above stated error

---

<div class="post-metadata">

**Author:** ![jianyiyang5](https://avatars.discourse-cdn.com/v4/letter/j/9dc877/32.png) [@jianyiyang5](https://discuss.huggingface.co/u/jianyiyang5)\
**Post date:** [April 25, 2023, 6:16am UTC](https://discuss.huggingface.co/t/error-401-client-error-unauthorized-for-url/19714/20 "2023-04-25T06:16:06Z")

</div>

Had a similar issue  
`401 Client Error: Unauthorized for url: https://huggingface.co/joeddav/xlm-roberta-large-xnli/resolve/main/sentencepiece.bpe.model`

Can download the file from web browser, but failed by python code. Do you know how to resolve this?

[Next page](https://discuss.huggingface.co/t/error-401-client-error-unauthorized-for-url/19714.md?page=2)
