What Is a 416 Status Code?
None of the ranges in the request’s Range header field1 overlap the current extent of the selected resource or that the set of ranges requested has been rejected due to invalid ranges or an excessive request of small or overlapping ranges.
For byte ranges, failing to overlap the current extent means that the first-byte-pos of all of the byte-range-spec values were greater than the current length of the selected representation. When this status code is generated in response to a byte-range request, the sender SHOULD generate a Content-Range header field specifying the current length of the selected representation2.
HTTP/1.1 416 Range Not Satisfiable Date: Fri, 20 Jan 2012 15:41:54 GMT Content-Range: bytes */47022
Note: Because servers are free to ignore Range, many implementations will simply respond with the entire selected representation in a 200 OK response. That is partly because most clients are prepared to receive a 200 OK to complete the task (albeit less efficiently) and partly because clients might not stop making an invalid partial request until they have received a complete representation. Thus, clients cannot depend on receiving a 416 Range Not Satisfiable response even when it is most appropriate.
- 1 Range RFC7233 Section 3.1
- 2 Content-Range RFC7233 Section 4.2
- Source: RFC7233 Section 4.4
416 CODE REFERENCES
Rails HTTP Status Symbol
Go HTTP Status Constant
Symfony HTTP Status Constant
Python2 HTTP Status Constant
Python3+ HTTP Status Constant
Python3.5+ HTTP Status Constant
Apache HttpComponents Core
416 status code example
GET /example.txt HTTP/1.1
In this example, the client is requesting a range of bytes that starts at 10,000 and ends at 20,000 for the file “example.txt”.
HTTP/1.1 416 Requested Range Not Satisfiable
Content-Range: bytes */10000
In the response, the server is indicating that the requested range of bytes is not available by returning a 416 status code. The “Content-Range” header indicates that the requested range is not satisfiable, as indicated by the “*” symbol, which means that no bytes are available for the requested range.
What causes a 416 status code?
There are several reasons why a client may receive a 416 status code, including:
- Requesting a range of bytes that’s outside the available range for a resource
- Requesting a resource that’s been deleted or modified since the last time it was accessed
- Requesting a range of bytes that overlaps with a previous range request
How to fix a 416 status code
You can fix a 416 status code with the following troubleshooting steps:
- Re-request a smaller range of bytes: If a client receives a 416 status code because it requested a range of bytes outside the available range for a resource, it can re-request a smaller range of bytes that’s within the available range.
- Verify that the requested resource is still available: If a client receives a 416 status code because it requested a resource that’s been deleted or modified, it can verify that the resource is still available and re-request it if necessary.
- Check for overlapping range requests: If a client receives a 416 status code because it requested a range of bytes that overlaps with a previous range request, it can check for overlapping range requests and adjust the request accordingly.
3 best practices for preventing 416 HTTP codes
These three best practices for a 416 status code can help you prevent them:
- Ensure that requested ranges of bytes are within the available range: To prevent a 416 status code from occurring, developers can ensure that requested ranges of bytes are within the available range for a particular resource.
- Avoid requesting resources that have been deleted: Developers can also prevent a 416 status code from occurring by avoiding requesting resources that have been deleted or modified since the last time they were accessed.
- Implement caching mechanisms: Caching can help prevent a 416 status code from occurring by reducing the number of requests made to a server and improving server performance.
- Learn about web development
- Learn about SEO
- Web development services from WebFX
- SEO services from WebFX
- MDN Web Docs