416 Range Not Satisfiable
The range specified by the Range header in the request cannot be fulfilled.
Usually happens because:
- ☑ Client requesting byte range offsets that exceed file sizes (e.g., Range
- ☑ Malformed range headers syntaxes.
🔍 Quick Checklist:
Meaning
The HTTP 416 Range Not Satisfiable client error status code indicates that a server cannot serve the requested ranges of a file. The most common cause is that the requested range is out of the file size boundaries.
Root Causes
- Client requesting byte range offsets that exceed file sizes (e.g., Range: bytes=5000-6000 on a 100-byte file).
- Malformed range headers syntaxes.
| Cause | Frequency |
|---|---|
| Client requesting byte range offsets that exceed file sizes (e.g., Range | ⭐⭐⭐⭐⭐ |
| Malformed range headers syntaxes. | ⭐⭐⭐⭐ |
Common Mistakes
- Failing to include the Content-Range header field indicating actual resource lengths.
- Misidentifying 416 as a server crash instead of a client query error.
How to Fix
Framework-Specific Examples
Express range checks returning 416.
app.get('/file', (req, res) => {
const fileSize = 200;
// If client range is out of bounds, return 416
res.status(416).set('Content-Range', `bytes */${fileSize}`).end();
});Server Configuration Examples
Nginx range filters.
# Nginx handles out of bounds ranges automatically returning 416Prevention
- Ensure client media players fetch header details (via HEAD requests) before compiling range requests.
Frequently Asked Questions (FAQ)
Q: What header must be returned with a 416 error?
The server must include a 'Content-Range' header specifying the actual size of the resource using the format 'bytes */size' (e.g. `Content-Range: bytes */500`).
Q: Why is 416 triggered by media players?
If a video player requests a chunk ahead of buffering limits or requests bytes after a file was dynamically modified and shrunk, the server returns 416.
Q: Is 416 cacheable?
No. The 416 Range Not Satisfiable status code is not cacheable by default.
Q: How do clients resolve 416 errors?
The client should read the actual file size from the returned Content-Range header, reset its request offsets, and issue a new request within bounds.