Hugging Face / Download errors

Causes and fixes for Hugging Face model download errors

Common errors when downloading models with transformers, huggingface_hub and the hf command, listed by exact message, each with its cause and fix.

Short answer

Hugging Face model files are served from overseas servers and a CDN that some networks cannot reach or that time out, and gated models also need approved access plus a login token, so one missing step makes model loading fail.

Setting up your environment this way avoids most errors on this page.

PracticeWhat happens if you skip it
On networks that cannot reach huggingface.co, set HF_ENDPOINT before importing, for example export HF_ENDPOINT=https://hf-mirror.com.Model loading fails to connect to huggingface.co or times out halfway.
Download the model to a local folder with hf download first, then load it from that folder in code.Every run checks files online, and any network hiccup becomes an error.
For gated models, request access on the website and wait for approval before downloading with a token.Downloads fail with 403 or 401, and switching tokens does not help.
Before downloading large models, set HF_HOME to a disk with enough space.The default cache is ~/.cache/huggingface, which fills the system drive on Windows.
After upgrading huggingface_hub to 1.x, switch scripts to the hf command and the token argument.Old scripts fail with huggingface-cli not found or unknown resume_download and use_auth_token arguments.

Troubleshooting by error message

Find your exact error message. Each entry gives the cause, the fix, and what may come up after the fix.

OSError: We couldn't connect to 'https://huggingface.co' to load this file, couldn't find it in the cached files

Cause: Your network cannot reach huggingface.co and the file is not in the local cache.

Fix: Set HF_ENDPOINT=https://hf-mirror.com before importing transformers and run again; when setting it in code, put it before every import.

What may come next: The mirror does not support login, so gated models need --token on the hf download command; if the mirror returns an xet-read-token 404, also set HF_HUB_DISABLE_XET=1.

HTTPSConnectionPool(host='cdn-lfs.hf.co', port=443): Read timed out. (read timeout=10)

Cause: The download is too slow and exceeds the default 10-second read timeout.

Fix: Set HF_HUB_DOWNLOAD_TIMEOUT=60 and HF_HUB_ETAG_TIMEOUT=60 and run again; files that finished downloading are read from the cache.

What may come next: On an unstable network a longer timeout only reduces failures, and large files can still drop midway.

Max retries exceeded with url: /api/models/... (Caused by NewConnectionError ... Network is unreachable)

Cause: There is no network route from your machine to huggingface.co, typical on networks that need a proxy.

Fix: Set HTTPS_PROXY to a working proxy, or use a mirror as in the first entry.

What may come next: huggingface_hub 1.x only reads the HTTP_PROXY and HTTPS_PROXY environment variables; per-call proxies arguments in old code no longer work.

GatedRepoError: 403 Client Error. Cannot access gated repo for url https://huggingface.co/meta-llama/Llama-2-7b-hf/resolve/main/tokenizer_config.json.

Cause: This is a gated model and your account has no access yet. If the message says is awaiting a review from the repo authors, your request is still pending.

Fix: Sign in on huggingface.co and request access on the model page; once approved, log in with hf auth login or set HF_TOKEN and download again.

What may come next: Models with manual review can take days, and a rejected request means no download.

RepositoryNotFoundError: 401 Client Error: Repository not found for url: https://huggingface.co/...

Cause: A private or gated repo was requested without logging in, or the repo name is wrong. Hugging Face returns 401 in all of these cases.

Fix: Open the URL from the error in a browser and check the repo name, including case; if it is correct, log in with hf auth login and retry.

Invalid user token. The token from HF_TOKEN environment variable is invalid.

Cause: The token in HF_TOKEN was deleted, expired, or copied with extra spaces.

Fix: Create a new read token under Settings → Access Tokens on huggingface.co and set HF_TOKEN again without spaces or line breaks.

What may come next: HF_TOKEN overrides the token saved by hf auth login, so logging in again has no effect while an old variable is still set.

huggingface-cli: command not found (after upgrading huggingface_hub to 1.x)

Cause: huggingface_hub 1.0 removed huggingface-cli and replaced it with the hf command.

Fix: Use hf instead: huggingface-cli download becomes hf download, and huggingface-cli login becomes hf auth login.

What may come next: Every huggingface-cli command in tutorials and old scripts has to be rewritten.

TypeError: hf_hub_download() got an unexpected keyword argument 'resume_download'

Cause: huggingface_hub 1.0 removed the resume_download, force_filename, local_dir_use_symlinks and use_auth_token arguments.

Fix: Delete resume_download and local_dir_use_symlinks, and rename use_auth_token to token.

What may come next: Third-party libraries written for older huggingface_hub may raise the same error and need upgrading.

Scientify is a cloud computer with research software installed and AI agents such as Codex and Claude Code built in. Describe what you need in one sentence, for example "embed these medical abstracts with BiomedBERT and cluster them by topic", and the agent uses the preinstalled Hugging Face to do the model download and computation, with no software to install and no code to write.

Compared with installing more on your own computer, the cloud computer reaches Hugging Face directly with no mirror, proxy or timeout settings, has transformers 5.21.0, huggingface_hub 1.32.0 and sentence-transformers 6.2.0 installed, and comes with more than ten medical and Chinese models such as BiomedBERT, MedCPT and Chinese BERT, and runs continue after you close your laptop.

The cloud computer comes with more computing power: CPU and GPU clusters can be called on demand for large-scale scientific computing. Compute is billed by the minutes you actually use, so nothing is wasted.

Cloud computer
4 vCPU · 8 GB
Top configuration, for data processing and small to medium jobs
Callable GPU
96 GB VRAM
Up to an RTX PRO 6000 per GPU; H800 80 GB and up to 8 × A10G also available
Callable CPU
224 cores · 3 TB
Largest spec, for large parallel computations

References

Frequently asked questions

Why does HF_ENDPOINT have no effect?

huggingface_hub reads environment variables at import time. In code, os.environ["HF_ENDPOINT"] must come before import transformers; in a terminal, run the program in the same terminal session.

Where are downloaded models stored?

By default in ~/.cache/huggingface/hub; HF_HOME moves it to another disk. hf download --local-dir downloads to a folder you choose.

Does an interrupted download start over?

No. Rerun the same command; files that already finished are read from the cache and only the rest are downloaded.

Run Hugging Face models with Scientify without setup

Upload your data, describe the computation, and Scientify runs it on a cloud computer that is already set up. New accounts get a free cloud computer and US$5 in credit.