416 Range Not Satisfiable
The HTTP 416 Range Not Satisfiable status code is a client error returned by the server to indicate the range or ranges specified by the client do not overlap with the available data and are not retrievable.
Usage
When the 416 Range Not Satisfiable error message is received, the client has requested partial content using the Range header. For byte ranges, if the first byte of the specified range is greater than the length of the resource, this error is returned.
One of the reasons partial ranges are requested is large file transfers, where the client wants to download a file in chunks. Using the Range header in the request, a file is effectively downloaded in pieces and in any order.
When the server satisfies the request and returns at least one of the requested ranges as a subset of the resource, 206 is returned to indicate success. Servers have the option to ignore range requests and return the resource in its entirety with the 200 status.
As part of the response, the server creates a Content-Range header specifying the current length of the data:
Content-Range: bytes */512
An asterisk * before the delimiter / indicates
an unsatisfiable range, followed by the total size
of the resource.
SEO impact
Search engines like Google will not index a URL with a 416 response status. URLs previously indexed will be removed from search results.
Example
The client requests bytes 1000 through 2000 of a resource. The server returns 416 Range Not Satisfiable because the file is only 512 bytes long. Using the information returned from the server about the total size, the client recreates the request with a valid range.
Request
GET /documents/main HTTP/1.1
Host: www.example.re
Range: bytes=1000-2000
Response
HTTP/1.1 416 Range Not Satisfiable
Content-Range: bytes */512
Alternative response when the server ignores the range
HTTP/1.1 200 OK
Content-Type: text/plain
Content-Length: 512
<entire 512 bytes in message body>
How to fix
The Range header specifies a byte range outside the resource boundaries. The most common cause is requesting bytes beyond the end of the file (for example, requesting bytes 1000-2000 from a file only 512 bytes long).
Verify the resource size first. Send a HEAD request to read the Content-Length header before constructing a range request. This prevents requesting bytes beyond the file boundary.
Check byte range math. Byte ranges are
zero-indexed and inclusive on both ends. A 512-byte
file has valid byte positions 0 through 511. The
range bytes=0-511 requests the entire file.
Off-by-one errors in range calculations are a
frequent source of 416 responses.
Handle resource changes. When resuming a download, the file on the server might have changed or been deleted since the last partial request. A range valid for the previous version becomes invalid for a shorter or different file. Re-check the resource size before resuming.
Remove the Range header. When partial content is not required, drop the Range header to request the full resource. The server returns 200 with the complete body instead.
Clear the browser cache. Browsers sometimes cache partial responses and construct invalid range requests on subsequent visits. Clearing the cache forces a fresh full request.
Server-side considerations. Some server
configurations limit which resource types support
range requests. Verify the server sends
Accept-Ranges: bytes in responses for the target
resource. When Accept-Ranges: none is present,
the server does not support partial requests for
the resource at all.
Code references
.NET
HttpStatusCode.RequestedRangeNotSatisfiable
Rust
http::StatusCode::RANGE_NOT_SATISFIABLE
Rails
:range_not_satisfiable
:requested_range_not_satisfiable
Go
http.StatusRequestedRangeNotSatisfiable
Symfony
Response::HTTP_REQUESTED_RANGE_NOT_SATISFIABLE
Python3.5+
http.HTTPStatus.REQUESTED_RANGE_NOT_SATISFIABLE
Java
HttpServletResponse.SC_REQUESTED_RANGE_NOT_SATISFIABLE
Apache HttpComponents Core
org.apache.hc.core5.http.HttpStatus.SC_REQUESTED_RANGE_NOT_SATISFIABLE
Angular
@angular/common/http/HttpStatusCode.RangeNotSatisfiable
Takeaway
The 416 Range Not Satisfiable status code is a client error returned when the partial range request sent by the client does not match the available data for the given resource. The server has the option to ignore the range request and send the entire resource.
See also
- RFC 9110: HTTP Semantics
- Google: HTTP status codes and network errors
- 200
- 206
- Range
- Content-Range
- Range request
- HTTP status codes
- HTTP headers