Safetensors HeaderTooLarge Error? Your Model File Isn't a Model — the 60-Second Diagnosis (2026)
TL;DR: Error while deserializing header: HeaderTooLarge almost never means anything is wrong with your GPU, your Python environment, or ComfyUI. It means the .safetensors file on your disk is not a safetensors file — it’s a 130-byte Git LFS pointer, an HTML login page, or a truncated download wearing the right filename. Check the file size first; the fix is a correct re-download, not a reinstall.
What you’ll be able to do:
- Diagnose any safetensors header error (
HeaderTooLarge,MetadataIncompleteBuffer,InvalidHeaderDeserialization) in under a minute with two shell commands - Tell exactly which wrong thing you downloaded — LFS pointer, HTML page, or partial file — and re-download it the way that can’t fail silently
- Verify a multi-gigabyte model file is intact before you waste a debugging session on it
Honest take: Don’t touch your ComfyUI install, your custom nodes, or your Python packages until you’ve run
ls -lhon the file the traceback names. In the overwhelming majority of reported cases this error is a bad download, and every minute spent reinstalling software is wasted.
What the error actually says
You’ll see some variant of this in ComfyUI, AUTOMATIC1111, transformers, or any tool built on the safetensors library:
safetensors_rust.SafetensorError: Error while deserializing header: HeaderTooLarge
Newer ComfyUI builds catch it and print a friendlier line — “The safetensors file is incomplete. Check the file size and make sure you have copied/downloaded it correctly.” — but plenty of loaders (custom nodes especially) still surface the raw Rust exception, and users reasonably assume their software is broken. Reports of this exact error span ComfyUI core, IPAdapter and LTX-Video custom nodes, transformers loading Llama checkpoints, and Meta’s own llama-cookbook.
To understand why the message is so misleading, you need ten seconds of format knowledge. Per the official safetensors spec, a safetensors file starts with:
- 8 bytes: an unsigned little-endian 64-bit integer — the size of the JSON header that follows
- N bytes: a JSON map of tensor names to dtypes, shapes, and data offsets
- Everything after: the raw tensor data
The library also enforces a 100MB ceiling on the header as a denial-of-service guard. So when the loader opens your file and reads the first 8 bytes, it expects a small number. If your “model” is actually a text file, those first 8 bytes are ASCII characters — version , <!DOCTYPE, whatever — which, interpreted as a 64-bit integer, is an astronomically large number. The library dutifully reports that the header is too large. The header isn’t too large. There is no header. The file is not a safetensors file.
That single insight collapses the whole debugging tree. The question is never “what’s wrong with my loader?” It’s “what did I actually download?”
The 60-second diagnosis
Run these two commands against the exact path in your traceback (Windows users: Git Bash ships both, or see the PowerShell equivalents below):
$ ls -lh models/clip/t5xxl_fp8_e4m3fn.safetensors
-rw-r--r-- 1 user user 135 Aug 2 09:14 t5xxl_fp8_e4m3fn.safetensors
$ head -c 200 models/clip/t5xxl_fp8_e4m3fn.safetensors
version https://git-lfs.github.com/spec/v1
oid sha256:5d7c6f6a9a44a1b1ed4e1a2b6f7f9c3f...
size 4893934120
That output is the smoking gun for the most common cause. The file that should be 4.89 GB is 135 bytes, and its contents are a Git LFS pointer — three lines of text that reference the real file instead of containing it. Each cause has its own signature:
| First bytes look like | File size | What you actually have | Fix |
|---|---|---|---|
version https://git-lfs.github.com/spec/v1 | Under 1 KB | Git LFS pointer file | git lfs pull (Cause 1) |
<!DOCTYPE html> or <html | A few KB–MB | Saved login/error page | Authenticated re-download (Cause 2) |
Binary garbage, error is MetadataIncompleteBuffer | GBs, but less than listed | Truncated download | Resume or re-download (Cause 3) |
GGUF, PK, or a pickle preamble | Plausible | Wrong format renamed | Get the actual safetensors build (Cause 4) |
On Windows PowerShell, the equivalents are:
Get-Item .\t5xxl_fp8_e4m3fn.safetensors | Select-Object Length
Get-Content .\t5xxl_fp8_e4m3fn.safetensors -TotalCount 3
If Get-Content prints readable text, you have your answer.
What should the size be? Check the “Files and versions” tab on the model’s Hugging Face page — every file lists its exact size. For the FLUX text encoders that trigger a huge share of these reports, the comfyanonymous/flux_text_encoders repo lists clip_l.safetensors at 246 MB, t5xxl_fp8_e4m3fn.safetensors at 4.89 GB, and t5xxl_fp16.safetensors at 9.79 GB. If your local copy is off by more than a rounding error, stop debugging software.
Cause 1: You cloned a repo and got Git LFS pointers
Hugging Face repos store weights with Git LFS. If you git clone a model repo on a machine where git-lfs isn’t installed — or you cloned with GIT_LFS_SKIP_SMUDGE=1, which several download guides recommend to grab configs quickly — every large file arrives as a pointer. Per the Git LFS spec, a pointer file is UTF-8 text, three key-value lines (version, oid sha256:..., size), and always under 1,024 bytes. A directory listing full of 130-byte “models” is unmistakable once you know to look.
This is exactly what bit users in transformers issue #27923 and llama-cookbook #884: the loader followed a path to a pointer file and reported HeaderTooLarge.
The fix, from inside the cloned repo:
git lfs install
git lfs pull
git lfs pull reads each pointer’s oid and size and replaces it with the real object. If git lfs isn’t on your system, install it first (sudo apt install git-lfs on Debian/Ubuntu, brew install git-lfs on macOS, the git-lfs.com installer on Windows).
Better yet, skip git for model downloads entirely — the next section’s tooling is built for this.
Cause 2: You downloaded an HTML page with a .safetensors name
Some downloads require authentication, and when you fetch them with wget/curl/a script without credentials, the server happily returns a login or error page — which your command happily saves as model.safetensors.
Two ecosystems produce this constantly:
- Civitai: many models require a logged-in session or an API token. Tools that script Civitai downloads have long trails of this failure — Wan2GP #1805 (“downloads HTML login page instead of model”) and Fooocus #2041 are typical. The fix is appending your API token (create one in Civitai account settings) to the download URL:
https://civitai.com/api/download/models/<id>?type=Model&format=SafeTensor&token=<YOUR_TOKEN>. - Hugging Face gated repos: FLUX.1-dev, Llama-family weights, and Stable Diffusion 3.x all require accepting a license while logged in. An unauthenticated fetch gets a 401 page. Log in first (
hf auth login) or pass--token.
The head -c 200 check from the diagnosis section exposes this instantly: HTML starts with <!DOCTYPE html> or <html, not tensor data. A related trap produces InvalidHeaderDeserialization instead of HeaderTooLarge — same family, same diagnosis, documented for SD3-in-ComfyUI where grabbing the wrong (or gated) variant of a file was the trigger.
Cause 3: The download died at 92%
If the first bytes look binary and the error reads MetadataIncompleteBuffer rather than HeaderTooLarge, your file started as a real safetensors download and got cut off — flaky Wi-Fi, a browser tab closed too early, a disk that filled up. The header parsed fine; the data the header promises isn’t all there. That’s the case in ComfyUI #3225 and the incomplete-ControlNet report in ComfyUI #6744 (ComfyUI 0.3.13, February 2025 — the report that shows off the clearer wrapped message).
Size-checking still works here, but the gap can be subtle — a 4.7 GB file that should be 4.89 GB looks fine at a glance. When in doubt, verify the hash. Hugging Face publishes the SHA-256 of every LFS file (click the file on the repo page; the oid is the hash):
sha256sum t5xxl_fp8_e4m3fn.safetensors
# compare against the sha256 listed on the HF file page
A mismatch means re-download. On a metered or slow connection, use a downloader that resumes instead of restarting — which brings us to the right tool.
The download method that can’t fail silently
All three causes share a root: ad-hoc downloads (browser save-as, bare wget, git clone without LFS) fail quietly, leaving a plausible-looking file. The official hf CLI fails loudly — it authenticates, verifies sizes, resumes interrupted transfers, and retries. It replaced huggingface-cli in huggingface_hub v0.34 (July 2025); the old command still works but warns.
pip install -U huggingface_hub
hf auth login # only needed for gated repos
hf download comfyanonymous/flux_text_encoders t5xxl_fp8_e4m3fn.safetensors \
--local-dir ./models/clip
Expected output ends with the resolved local path; a gated repo without login fails with an explicit 401 instead of a poisoned file. Re-running the same command after an interruption resumes from where it stopped rather than starting over — the fix for Cause 3 on bad connections.
Two habits worth adopting alongside it:
- Keep the model library on a drive with headroom. A full disk mid-download is a classic Cause 3 trigger, and model libraries grow fast — a FLUX setup with both T5 encoders is ~15 GB before you add a single checkpoint. If you’re reorganizing storage anyway, our SSD guide for local AI covers why a dedicated NVMe drive like a Samsung 990 Pro is the right home for it, and our backup guide covers not having to re-download 200 GB after a drive failure.
- Verify once, trust thereafter. After any multi-gigabyte download from a new source, one
sha256sumagainst the published hash buys you certainty. It’s 30 seconds against a potential evening of ghost-hunting.
If you’re on hotel Wi-Fi or a capped connection and need a big model now, it’s also worth remembering that a cloud GPU box sits on datacenter bandwidth — pulling a 10 GB encoder onto a RunPod instance takes seconds, and you can experiment there while your home download crawls.
Cause 4: It was never a safetensors file
Rarer, but real: the file is complete and healthy — it’s just not safetensors. A GGUF quantization renamed to .safetensors (the first four bytes will literally read GGUF), an old pickle-format .ckpt given the wrong extension by a mirror, or a zip. The header check exposes all of these the same way: the first bytes aren’t a small little-endian integer followed by {.
The fix is not conversion trickery — it’s downloading the artifact your tool actually loads. ComfyUI loads GGUF only through dedicated custom nodes; core loaders want safetensors. If you’ve got a GGUF and a GGUF-shaped problem, that’s a different article — we’ve covered the unknown model architecture GGUF error separately.
One caveat for completeness: a small number of reports trace to a genuinely outdated safetensors Python package failing on newly-minted files with big metadata blocks — several ComfyUI custom-node threads resolved with pip install -U safetensors. Try it after the file checks pass, never before; upgrading packages while the real problem is a 135-byte pointer file just scrambles your environment for nothing.
Fix order, start to finish
ls -lhthe exact file in the traceback. Compare against the size listed on the source page. Wildly small → Cause 1 or 2.head -c 200the file. LFS pointer text →git lfs pull. HTML → authenticate and re-download. Binary → step 3.- Error says
MetadataIncompleteBufferor the size is slightly short →sha256sumagainst the published hash → resume withhf download. - First bytes read
GGUF/PK/pickle → wrong format; get the safetensors build. - All checks pass and it still fails →
pip install -U safetensors, restart the app (the server process, not the browser tab), and try a known-good file to isolate.
The pattern behind this whole error family is the one that runs through our other troubleshooting guides — ComfyUI IMPORT FAILED, black image output, LM Studio failed-to-load: the error message names the symptom, and the evidence for the cause is one deliberate look away. Coding-tool users hit the same LFS-pointer trap pulling model repos for local backends; our sister site aicoderscope.com covers the local-coding-stack side, and aifoss.dev covers the FOSS tooling angle.
FAQ
Does HeaderTooLarge ever mean the file is too big for my RAM or VRAM? No. The check happens before any tensor data is read, and it’s about the JSON header’s declared size, not the model’s. A 70B model on a 4 GB GPU produces out-of-memory errors, not header errors — that’s a different fix.
Why did the same file work on my other machine?
Because on the other machine it is a different file. Copying a git-cloned repo with rsync/scp copies whatever is there — if the source had real weights and the destination clone had pointers (or the copy was interrupted), the two paths hold different bytes with the same names. Hash both and compare.
Can I repair a truncated safetensors file?
No. The missing bytes are simply absent, and safetensors has no redundancy to reconstruct them. Resume the download with hf download (which continues partial transfers) or delete and re-fetch.
Is this a security problem — could a malicious file exploit the header?
The 100MB header cap exists precisely to bound parsing abuse, and safetensors was designed (unlike pickle-based .ckpt) so loading a file can’t execute code. A garbage file fails loudly with these errors instead of running anything — annoying, but safe.
My error is InvalidHeaderDeserialization, not HeaderTooLarge. Same fix?
Same diagnosis, yes. HeaderTooLarge = the declared header size is absurd (file is text/HTML/pointer). InvalidHeaderDeserialization = the size parsed but the “JSON” is malformed (wrong file variant, corruption near the start). MetadataIncompleteBuffer = valid header, missing data (truncation). All three resolve through the same size → first-bytes → hash checklist.
Sources
- safetensors format specification — Hugging Face / GitHub
- The safetensors file is incomplete (MetadataIncompleteBuffer, ComfyUI 0.3.13) — ComfyUI issue #6744
- Error while deserializing header: HeaderTooLarge — ComfyUI issue #5826
- SafetensorError: HeaderTooLarge loading Llama 2 70B — transformers issue #27923
- HeaderTooLarge from LFS pointer files — llama-cookbook issue #884
- Git LFS pointer file specification — git-lfs/git-lfs
- FLUX text encoder file sizes — comfyanonymous/flux_text_encoders, Hugging Face
- Say hello to
hf: the renamed Hugging Face CLI (huggingface_hub v0.34) — Hugging Face blog - Civitai downloads returning HTML login page — Wan2GP issue #1805
- Civitai model corrupted / not downloading — Fooocus issue #2041
- MetadataIncompleteBuffer on model load — ComfyUI issue #3225
- Fixing InvalidHeaderDeserialization with SD3 in ComfyUI — kombitz
Last updated August 2, 2026. Prices and specs change; verify current rates before purchasing.
Was this article helpful?
Thanks for the feedback — it helps improve future articles.
Need hands-on help?
I offer 1-on-1 technical consulting for local AI setup, GPU selection, and AI coding tool configuration — same topics covered on this site.
Book a session — $49 / hour →