416 Range Not Satisfiable: Invalid Range Request
Range header is invalid or out of bounds. This typically happens when a client requests a byte range that starts beyond the end of the resource. The server includes a Content-Range header with the actual size of the resource (e.g., Content-Range: bytes */1000) to help the client correct its request.
How Range Requests Work
A client sends a Range header to request only a portion of a resource, typically for resuming downloads or video streaming. The server responds with 206 Partial Content if the range is valid. If the range is invalid (e.g., starts after the end of the file), the server returns 416 Range Not Satisfiable.
Common Causes of 416 Errors
| Cause | Example | How to Fix |
|---|---|---|
| Start byte beyond resource size | Resource is 1000 bytes, client requests Range: bytes=2000-3000. | Use the Content-Range from the 416 response to correct the range. |
| Invalid range syntax | Range: bytes=abc-def (non‑numeric). | Ensure the range is in the format bytes=start-end with numeric values. |
| Multi‑range with invalid ranges | One range is valid, another is out of bounds; server may return 416. | Check all ranges, or request only valid ranges. |
| Client incorrectly calculates size | Client assumes a larger size than the actual resource. | Get the resource size from the Accept-Ranges or Content-Range header. |
| Proxy or CDN stripping Range header | Intermediate server removes or alters the Range header. | Check proxy configuration to preserve the Range header. |
Example: 416 Response
A client requests a range starting at 2000 bytes, but the resource is only 1000 bytes:
How to Fix 416 Errors
- If you're a client developer: Always fetch the resource size first (e.g., via a HEAD request or check the
Content-Lengthin a 200 response). Use theContent-Rangeheader from a 416 response to get the actual size and adjust your range accordingly. - If you're a server developer: Ensure you handle range requests correctly. Validate the range and return 416 with the
Content-Range: bytes */{total}header. This helps clients correct their requests. - If you're an end‑user: This error is usually caused by a faulty download manager or media player. Try restarting the download or using a different client.
Range Request Best Practices
- Use HEAD requests – send a HEAD request to get the
Content-Lengthbefore making a range request. - Handle 416 gracefully – if you receive 416, use the
Content-Rangeto correct your range and retry. - Avoid overlapping ranges – ensure the ranges you request do not overlap unnecessarily.
- Support multi‑ranges – if you need multiple ranges, use the
multipart/byterangesformat.
Frequently Asked Questions
Is 416 a client error or a server error?
It's a client error (4xx) because the client requested an invalid range. The server is working correctly but cannot satisfy the request.
What is the Content-Range header used for in a 416 response?
It tells the client the total size of the resource, allowing the client to correct its range. The format is Content-Range: bytes */{total_size}.
Can I use 416 for range requests that are beyond the end?
Yes, that is exactly the purpose of 416. If the range start is beyond the resource's size, the server should return 416.