Hugging Face: Cannot access gated repo (401)
The model is "gated" on Hugging Face: You must first accept the license and sign in with a token when downloading it.
The message
huggingface_hub.errors.GatedRepoError: 401 Client Error. Cannot access gated repo for url https://huggingface.co/…/resolve/main/… Access to model … is restricted. You must have access to it and be authenticated to access it. Please log in.
Affects: Hugging Face (Hub and hf CLI), ComfyUI, Wan2GP (WanGP), SwarmUI, InvokeAI
Why is this happening?
Some models (e.g. FLUX.1-dev or Llama) are protected. The download only works if you have accepted the terms in the browser and the program is signed in with your Hugging Face account. If either one is missing, the server responds with 401 or 403. For some models, the provider must approve your request manually first.
How to fix it
- Sign in to huggingface.co in your browser, open the model page, and click "Agree and send request to access repo". Fill out any additional fields if asked.
- Check on the model page whether access has already been approved. If it says the request is still being reviewed (pending), you have to wait for the provider to approve it.
- Create a token with the role "Read" at https://huggingface.co/settings/tokens using "New token". Treat the token like a password.
- Install the Hugging Face command line if it is not already installed, e.g. with
pip install -U huggingface_hub(or with the official installer from the Hugging Face docs). - Sign in in the terminal:
hf auth login. Follow the link or paste your token. Usehf auth whoamito check whether the sign-in worked. - Restart the program (e.g. ComfyUI or Wan2GP) so it uses the saved token, then start the download again. Alternatively, download the file directly with
hf download <repo-id> <dateiname> --local-dir <zielordner>.
Better not: Do not download locked models from random mirror sites to bypass the sign-in, and do not share your token in forums or screenshots.
Set up from scratch again
If it still doesn’t work after that, a fresh setup step by step often helps:
- Set up and maintain ComfyUI on Windows
Desktop or Portable, where the models belong, sharing models with other programs, safely installing custom nodes, updates, startup options … - Your First Image with ComfyUI
Install Comfy Desktop, learn the interface, and create your first AI image with FLUX.2 [small] 4B or Z-Image Turbo. - Your First AI Video with LTX in ComfyUI
Use LTX-2.3 in ComfyUI to create short videos with sound from text or an image. Template, files, settings, and license.
Terms for this
Similar errors
- Hugging Face download stops or hangs (.incomplete)
- SafetensorError: incomplete metadata / MetadataIncompleteBuffer
- The NVIDIA driver on your system is too old
- SwarmUI: All available backends failed to load the model (the real error is in the log)
- Hugging Face: 429 Client Error: Too Many Requests / We had to rate limit you – too many requests, you’re being throttled
Sources
- https://huggingface.co/docs/hub/models-gated
- https://huggingface.co/docs/hub/security-tokens
- https://huggingface.co/docs/huggingface_hub/guides/cli
- https://raw.githubusercontent.com/huggingface/huggingface_hub/main/src/huggingface_hub/utils/_http.py
Checked on Oct 21, 2026. Didn't help? Ask in the forum and name the graphics card, program, and the full message.