Skip to content

DNS error while download file with xet storage backend #3155

Description

@iNARI777

Describe the bug

I encountered a DNS error when using the API from huggingface_hub to download model files from HuggingFace. This issue only occurs with files stored using xet storage—files stored with LFS or regular git can be downloaded without any problems.

Here is the core code snippet I used to download the model files. Since my machine cannot connect to the public internet directly, I have set up an HTTP proxy in the code.

Could you please advise me on how to resolve this issue? Thank you!

Reproduction

import requests

from huggingface_hub import hf_hub_download, configure_http_backend


def set_hf_http_proxy(http_proxy):
    proxies = {
        "http": http_proxy,
        "https": http_proxy
    }
    def session_factory():
        session = requests.Session()
        session.proxies = proxies
        return session
    configure_http_backend(session_factory)


http_proxy = "http://xx.xxx.xx.xxx:xxxx"
set_hf_http_proxy(http_proxy)

repo_id = "Qwen/Qwen3-Reranker-0.6B"
filename = "tokenizer.json"
repo_type = "model"
revision = "main"
local_dir = "./"
cache_dir = "./"
local_dir_use_symlinks = False

hf_hub_download(
    repo_id=repo_id,
    filename=filename,
    repo_type=repo_type,
    revision=revision,
    local_dir=local_dir,
    cache_dir=cache_dir,
    local_dir_use_symlinks=local_dir_use_symlinks,
    resume_download=True
)

Logs

$ python file_download.py
tokenizer.json:   0%|                                                                                                                                                        | 0.00/11.4M [00:00<?, ?B/s]{"timestamp":"2025-06-09T12:32:41.363157Z","level":"WARN","fields":{"message":"Reqwest(reqwest::Error { kind: Request, url: \"https://cas-server.xethub.hf.co/reconstruction/6aec39639a0a2d1ca966356b8c2b8426a484f80ff80731f44fa8482040713bdf\", source: hyper_util::client::legacy::Error(Connect, ConnectError(\"dns error\", Custom { kind: Uncategorized, error: \"failed to lookup address information: Temporary failure in name resolution\" })) }). Retrying..."},"filename":"/home/runner/work/xet-core/xet-core/cas_client/src/http_client.rs","line_number":200}
{"timestamp":"2025-06-09T12:32:41.363213Z","level":"WARN","fields":{"message":"Retry attempt #0. Sleeping 1.053998972s before the next attempt"},"filename":"/root/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/reqwest-retry-0.7.0/src/middleware.rs","line_number":171}
{"timestamp":"2025-06-09T12:32:42.435602Z","level":"WARN","fields":{"message":"Reqwest(reqwest::Error { kind: Request, url: \"https://cas-server.xethub.hf.co/reconstruction/6aec39639a0a2d1ca966356b8c2b8426a484f80ff80731f44fa8482040713bdf\", source: hyper_util::client::legacy::Error(Connect, ConnectError(\"dns error\", Custom { kind: Uncategorized, error: \"failed to lookup address information: Temporary failure in name resolution\" })) }). Retrying..."},"filename":"/home/runner/work/xet-core/xet-core/cas_client/src/http_client.rs","line_number":200}
{"timestamp":"2025-06-09T12:32:42.435636Z","level":"WARN","fields":{"message":"Retry attempt #1. Sleeping 1.606925917s before the next attempt"},"filename":"/root/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/reqwest-retry-0.7.0/src/middleware.rs","line_number":171}
{"timestamp":"2025-06-09T12:32:44.061634Z","level":"WARN","fields":{"message":"Reqwest(reqwest::Error { kind: Request, url: \"https://cas-server.xethub.hf.co/reconstruction/6aec39639a0a2d1ca966356b8c2b8426a484f80ff80731f44fa8482040713bdf\", source: hyper_util::client::legacy::Error(Connect, ConnectError(\"dns error\", Custom { kind: Uncategorized, error: \"failed to lookup address information: Temporary failure in name resolution\" })) }). Retrying..."},"filename":"/home/runner/work/xet-core/xet-core/cas_client/src/http_client.rs","line_number":200}
{"timestamp":"2025-06-09T12:32:44.061664Z","level":"WARN","fields":{"message":"Retry attempt #2. Sleeping 10.395844705s before the next attempt"},"filename":"/root/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/reqwest-retry-0.7.0/src/middleware.rs","line_number":171}
{"timestamp":"2025-06-09T12:32:54.482074Z","level":"WARN","fields":{"message":"Reqwest(reqwest::Error { kind: Request, url: \"https://cas-server.xethub.hf.co/reconstruction/6aec39639a0a2d1ca966356b8c2b8426a484f80ff80731f44fa8482040713bdf\", source: hyper_util::client::legacy::Error(Connect, ConnectError(\"dns error\", Custom { kind: Uncategorized, error: \"failed to lookup address information: Temporary failure in name resolution\" })) }). Retrying..."},"filename":"/home/runner/work/xet-core/xet-core/cas_client/src/http_client.rs","line_number":200}
{"timestamp":"2025-06-09T12:32:54.482106Z","level":"WARN","fields":{"message":"Retry attempt #3. Sleeping 23.1864274s before the next attempt"},"filename":"/root/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/reqwest-retry-0.7.0/src/middleware.rs","line_number":171}
{"timestamp":"2025-06-09T12:33:17.684544Z","level":"WARN","fields":{"message":"Reqwest(reqwest::Error { kind: Request, url: \"https://cas-server.xethub.hf.co/reconstruction/6aec39639a0a2d1ca966356b8c2b8426a484f80ff80731f44fa8482040713bdf\", source: hyper_util::client::legacy::Error(Connect, ConnectError(\"dns error\", Custom { kind: Uncategorized, error: \"failed to lookup address information: Temporary failure in name resolution\" })) }). Retrying..."},"filename":"/home/runner/work/xet-core/xet-core/cas_client/src/http_client.rs","line_number":200}
{"timestamp":"2025-06-09T12:33:17.684571Z","level":"WARN","fields":{"message":"Retry attempt #4. Sleeping 38.695224788s before the next attempt"},"filename":"/root/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/reqwest-retry-0.7.0/src/middleware.rs","line_number":171}
{"timestamp":"2025-06-09T12:33:56.402793Z","level":"WARN","fields":{"message":"Reqwest(reqwest::Error { kind: Request, url: \"https://cas-server.xethub.hf.co/reconstruction/6aec39639a0a2d1ca966356b8c2b8426a484f80ff80731f44fa8482040713bdf\", source: hyper_util::client::legacy::Error(Connect, ConnectError(\"dns error\", Custom { kind: Uncategorized, error: \"failed to lookup address information: Temporary failure in name resolution\" })) }). Retrying..."},"filename":"/home/runner/work/xet-core/xet-core/cas_client/src/http_client.rs","line_number":200}
{"timestamp":"2025-06-09T12:33:56.402865Z","level":"ERROR","fields":{"message":"error invoking get_reconstruction api, error: ReqwestMiddlewareError(Middleware(Request failed after 5 retries\n\nCaused by:\n    0: error sending request for url (https://cas-server.xethub.hf.co/reconstruction/6aec39639a0a2d1ca966356b8c2b8426a484f80ff80731f44fa8482040713bdf)\n    1: client error (Connect)\n    2: dns error: failed to lookup address information: Temporary failure in name resolution\n    3: failed to lookup address information: Temporary failure in name resolution))","caller":"/home/runner/work/xet-core/xet-core/cas_client/src/http_client.rs:286"},"filename":"/home/runner/work/xet-core/xet-core/error_printer/src/lib.rs","line_number":28}
tokenizer.json:   0%|
Traceback (most recent call last):
  File "/home/hadoop-aipnlp/projects/nlp-llm-tools/file_download.py", line 29, in <module>
    hf_hub_download(
  File "/home/hadoop-aipnlp/conda/envs/llm/lib/python3.12/site-packages/huggingface_hub/utils/_validators.py", line 114, in _inner_fn
    return fn(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^
  File "/home/hadoop-aipnlp/conda/envs/llm/lib/python3.12/site-packages/huggingface_hub/file_download.py", line 988, in hf_hub_download
    return _hf_hub_download_to_local_dir(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/hadoop-aipnlp/conda/envs/llm/lib/python3.12/site-packages/huggingface_hub/file_download.py", line 1290, in _hf_hub_download_to_local_dir
    _download_to_tmp_and_move(
  File "/home/hadoop-aipnlp/conda/envs/llm/lib/python3.12/site-packages/huggingface_hub/file_download.py", line 1710, in _download_to_tmp_and_move
    xet_get(
  File "/home/hadoop-aipnlp/conda/envs/llm/lib/python3.12/site-packages/huggingface_hub/file_download.py", line 627, in xet_get
    download_files(
RuntimeError: Data processing error: CAS service error : ReqwestMiddleware Error: Request failed after 5 retries

System info

- huggingface_hub version: 0.32.4
- Platform: Linux-4.18.0-147.mt20200626.413.el8_1.x86_64-x86_64-with-glibc2.17
- Python version: 3.12.0
- Running in iPython ?: No
- Running in notebook ?: No
- Running in Google Colab ?: No
- Running in Google Colab Enterprise ?: No
- Token path ?: /home/hadoop-aipnlp/.cache/huggingface/token
- Has saved token ?: False
- Configured git credential helpers: 
- FastAI: N/A
- Tensorflow: N/A
- Torch: 2.2.2
- Jinja2: 3.1.3
- Graphviz: N/A
- keras: N/A
- Pydot: N/A
- Pillow: 10.3.0
- hf_transfer: N/A
- gradio: N/A
- tensorboard: N/A
- numpy: 1.26.4
- pydantic: 2.6.4
- aiohttp: 3.11.18
- hf_xet: 1.1.3
- ENDPOINT: https://huggingface.co
- HF_HUB_CACHE: /home/hadoop-aipnlp/.cache/huggingface/hub
- HF_ASSETS_CACHE: /home/hadoop-aipnlp/.cache/huggingface/assets
- HF_TOKEN_PATH: /home/hadoop-aipnlp/.cache/huggingface/token
- HF_STORED_TOKENS_PATH: /home/hadoop-aipnlp/.cache/huggingface/stored_tokens
- 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
- HF_HUB_ETAG_TIMEOUT: 10
- HF_HUB_DOWNLOAD_TIMEOUT: 10

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions