Error 401 Client Error: Unauthorized for url

I’m surprised you came up with such a workaround…:sweat_smile:

It seems that the token area is being modified, and the operation has changed twice today alone. Well, it’s probably best to wait for it to be fixed.

i agree john
i thought i was going crazy, but over the last 48 hours or so token procedures appear to change
and yes, putting it into a secret worked for me for some models too, still.
and yes, previously omitting tokens granted access for me as well.
i cant confirm CAPPING tokens, not yet at least
i cant really keep track of what i can and cant confirm or when

likely tomorrow itll change again eh?
i need a nice tall glass of drink

1 Like

yes this works (but I don’t know why the below cannot work for me:
from huggingface_hub import notebook_login
notebook_login()

1 Like

thank you so much! it works for me

1 Like

I’m having a similar issue now and I’m downloading stabilityai/stable-diffusion-xl-base-1.0 encounter RuntimeError: Data processing error: CAS service error : Reqwest Error: HTTP status client error (401 Unauthorized), domain: https:cas-server.xethub.hf.co/reconstruction/4cb12f8b6ebb11f02b908c4c878871cae90cbe3bad06db19e97336df6b7f3a6e I don’t understand why public repositories need authorization as well, and even if I give the correct token, it will still get an error, and I download other public models that don’t happen at the same time , I wouldn’t go wrong downloading the model on other PCs either

1 Like

Hmm… How about pip install -U huggingface_hub[hf_xet] ?

I’m getting the same error and I have hf-xet 1.1.5. I’m behind a firewall but have no problems with requests to other URLs.

1 Like

Hi @XPW123 thanks for the report - are you behind any firewalls when you make this request? If so, could you make sure you have the following domains allowlisted:

cas-bridge.xethub.hf.co
transfer.xethub.hf.co
cas-server.xethub.hf.co

If not (or if that doesn’t help), could you open an issue on the xet-core repository and we can investigate there?

1 Like

Hi @alfredgabal :waving_hand:

Could you provide the full error you’re seeing?

Also, do you have the following URLs allowlisted:

cas-bridge.xethub.hf.co
transfer.xethub.hf.co
cas-server.xethub.hf.co
1 Like

Hi @jsulz , thanks for the reply. I do get a response when I curl those three URLs. Here’s the full error message (I replaced some “https” with “h***s” because the page doesn’t let me post more than two links):

Fetching 83 files: 0%| | 0/83 [00:00<?, ?it/s]{“timestamp”:“2025-07-01T17:37:59.153575Z”,“level”:“ERROR”,“fields”:{“message”:“error downloading range, error: ReqwestMiddlewareError(Middleware(error sending request\n\nCaused by:\n 0: client error (SendRequest)\n 1: connection error\n 2: peer closed connection without sending TLS close_notify: h***s://docs.rs/rustls/latest/rustls/manual/_03_howto/index.html#unexpected-eof))”,“caller”:“/home/runner/work/xet-core/xet-core/cas_client/src/download_utils.rs:528”},“filename”:“/home/runner/work/xet-core/xet-core/error_printer/src/lib.rs”,“line_number”:28}
{“timestamp”:“2025-07-01T18:05:15.966119Z”,“level”:“WARN”,“fields”:{“message”:“Reqwest(reqwest::Error { kind: Request, source: hyper_util::client::legacy::Error(SendRequest, hyper::Error(Io, Os { code: 104, kind: ConnectionReset, message: "Connection reset by peer" })) }). Retrying…”},“filename”:“/home/runner/work/xet-core/xet-core/cas_client/src/http_client.rs”,“line_number”:242}
{“timestamp”:“2025-07-01T18:05:15.970285Z”,“level”:“WARN”,“fields”:{“message”:“Retry attempt #0. Sleeping 2.750031341s before the next attempt”},“filename”:“/root/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/reqwest-retry-0.7.0/src/middleware.rs”,“line_number”:171}

Fetching 83 files: 1%| | 1/83 [43:04<58:51:31, 2584.04s/it]
Fetching 83 files: 17%|█▋ | 14/83 [43:04<3:32:15, 184.57s/it]
{“timestamp”:“2025-07-01T18:06:30.649359Z”,“level”:“ERROR”,“fields”:{“message”:“error downloading range, error: ReqwestMiddlewareError(Middleware(error sending request\n\nCaused by:\n 0: client error (SendRequest)\n 1: connection error\n 2: peer closed connection without sending TLS close_notify: h***s://docs.rs/rustls/latest/rustls/manual/_03_howto/index.html#unexpected-eof))”,“caller”:“/home/runner/work/xet-core/xet-core/cas_client/src/download_utils.rs:528”},“filename”:“/home/runner/work/xet-core/xet-core/error_printer/src/lib.rs”,“line_number”:28}
Traceback (most recent call last):
File “/home/ag/Models/molmo-inference.py”, line 15, in
model = AutoModelForCausalLM.from_pretrained(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/home/ag/conda/Molmo/lib/python3.12/site-packages/transformers/models/auto/auto_factory.py”, line 593, in from_pretrained
return model_class.from_pretrained(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/home/ag/conda/Molmo/lib/python3.12/site-packages/transformers/modeling_utils.py”, line 311, in _wrapper
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File “/home/ag/conda/Molmo/lib/python3.12/site-packages/transformers/modeling_utils.py”, line 4674, in from_pretrained
checkpoint_files, sharded_metadata = _get_resolved_checkpoint_files(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/home/ag/conda/Molmo/lib/python3.12/site-packages/transformers/modeling_utils.py”, line 1295, in _get_resolved_checkpoint_files
checkpoint_files, sharded_metadata = get_checkpoint_shard_files(
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/home/ag/conda/Molmo/lib/python3.12/site-packages/transformers/utils/hub.py”, line 1110, in get_checkpoint_shard_files
cached_filenames = cached_files(
^^^^^^^^^^^^^
File “/home/ag/conda/Molmo/lib/python3.12/site-packages/transformers/utils/hub.py”, line 557, in cached_files
raise e
File “/home/ag/conda/Molmo/lib/python3.12/site-packages/transformers/utils/hub.py”, line 485, in cached_files
snapshot_download(
File “/home/ag/conda/Molmo/lib/python3.12/site-packages/huggingface_hub/utils/_validators.py”, line 114, in _inner_fn
return fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^
File “/home/ag/conda/Molmo/lib/python3.12/site-packages/huggingface_hub/_snapshot_download.py”, line 327, in snapshot_download
thread_map(
File “/home/ag/conda/Molmo/lib/python3.12/site-packages/tqdm/contrib/concurrent.py”, line 69, in thread_map
return _executor_map(ThreadPoolExecutor, fn, *iterables, **tqdm_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/home/ag/conda/Molmo/lib/python3.12/site-packages/tqdm/contrib/concurrent.py”, line 51, in _executor_map
return list(tqdm_class(ex.map(fn, *iterables, chunksize=chunksize), **kwargs))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/home/ag/conda/Molmo/lib/python3.12/site-packages/tqdm/std.py”, line 1181, in iter
for obj in iterable:
^^^^^^^^
File “/home/ag/conda/Molmo/lib/python3.12/concurrent/futures/_base.py”, line 619, in result_iterator
yield _result_or_cancel(fs.pop())
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/home/ag/conda/Molmo/lib/python3.12/concurrent/futures/_base.py”, line 317, in _result_or_cancel
return fut.result(timeout)
^^^^^^^^^^^^^^^^^^^
File “/home/ag/conda/Molmo/lib/python3.12/concurrent/futures/_base.py”, line 449, in result
return self.__get_result()
^^^^^^^^^^^^^^^^^^^
File “/home/ag/conda/Molmo/lib/python3.12/concurrent/futures/_base.py”, line 401, in __get_result
raise self._exception
File “/home/ag/conda/Molmo/lib/python3.12/concurrent/futures/thread.py”, line 59, in run
result = self.fn(*self.args, **self.kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/home/ag/conda/Molmo/lib/python3.12/site-packages/huggingface_hub/_snapshot_download.py”, line 301, in _inner_hf_hub_download
return hf_hub_download(
^^^^^^^^^^^^^^^^
File “/home/ag/conda/Molmo/lib/python3.12/site-packages/huggingface_hub/utils/_validators.py”, line 114, in _inner_fn
return fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^
File “/home/ag/conda/Molmo/lib/python3.12/site-packages/huggingface_hub/file_download.py”, line 1008, in hf_hub_download
return _hf_hub_download_to_cache_dir(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/home/ag/conda/Molmo/lib/python3.12/site-packages/huggingface_hub/file_download.py”, line 1161, in _hf_hub_download_to_cache_dir
_download_to_tmp_and_move(
File “/home/ag/conda/Molmo/lib/python3.12/site-packages/huggingface_hub/file_download.py”, line 1710, in _download_to_tmp_and_move
xet_get(
File “/home/ag/conda/Molmo/lib/python3.12/site-packages/huggingface_hub/file_download.py”, line 627, in xet_get
download_files(
RuntimeError: Data processing error: CAS service error : Reqwest Error: HTTP status client error (401 Unauthorized), domain: https://cas-server.xethub.hf.co/reconstruction/c4ac4717bebd033e12a7f0036103c7383614198445be5970f0187fa2bfc0d9c3

Thanks for your help!

2 Likes

Thanks for the additional details! There is potentially some work we can do here on our authentication to the storage system backing these files.

I opened up an issue here on the xet-core repo, since the issue can potentially be addressed there.

Feel free to add any additional context or subscribe to the issue there to get updates (I’ll also post here when we think we’ve resolved the issue).

2 Likes

Hey @alfredgabal - just wanted to let you know that we believe the root cause of this issue was not providing enough buffer between a token refresh and when that same token was set to expire. The PR for this is here and will be included in our next release.

Thank you for reporting!

1 Like