Skip to content

416 Range Not Satisfiable

Description

The 416 Range Not Satisfiable status code indicates that the server cannot serve the requested ranges. This status code is returned when none of the ranges in the request's Range header field overlap the current extent of the selected resource or when the request asks for a portion of the resource that lies beyond its bounds.

This status code is commonly used when: - A client requests a range that is entirely outside the valid range of a resource - A client uses the Range header for a resource that doesn't support range requests - A client requests a range for a resource that no longer exists or has zero length - The If-Range precondition fails

The server should include a Content-Range header field with a byte-range-resp-spec of "*" and an instance-length specifying the current length of the representation.

Syntax

The server responds with a 416 Range Not Satisfiable status:

HTTP/1.1 416 Range Not Satisfiable
Content-Range: bytes */[total size]
Content-Type: application/json
Content-Length: [length in bytes]

{
  "error": "Range Not Satisfiable",
  "message": "The requested range is not satisfiable"
}

Examples

Invalid Range Example

A client requests a range that is entirely outside the valid range of a file:

Client Request:

GET /files/document.pdf HTTP/1.1
Host: files.example.com
Range: bytes=10000000-10000500

Server Response:

HTTP/1.1 416 Range Not Satisfiable
Content-Range: bytes */2500000
Content-Type: application/json
Content-Length: 187

{
  "error": "Range Not Satisfiable",
  "message": "The requested range is outside the bounds of the resource",
  "resource_size": 2500000,
  "requested_range": "10000000-10000500"
}

Zero-Length Resource Example

A client requests a range for a resource that has zero length:

Client Request:

GET /files/empty-file.txt HTTP/1.1
Host: files.example.com
Range: bytes=0-499

Server Response:

HTTP/1.1 416 Range Not Satisfiable
Content-Range: bytes */0
Content-Type: text/plain
Content-Length: 78

The requested range cannot be satisfied because the resource has a length of 0 bytes.

Multiple Invalid Ranges Example

A client requests multiple ranges, all of which are invalid:

Client Request:

GET /videos/sample.mp4 HTTP/1.1
Host: media.example.com
Range: bytes=5000000-5001000, 6000000-6001000, 7000000-7001000

Server Response:

HTTP/1.1 416 Range Not Satisfiable
Content-Range: bytes */4500000
Content-Type: application/json
Content-Length: 243

{
  "error": "Range Not Satisfiable",
  "message": "None of the requested ranges are satisfiable",
  "resource_size": 4500000,
  "requested_ranges": [
    "5000000-5001000",
    "6000000-6001000",
    "7000000-7001000"
  ],
  "valid_range": "0-4499999"
}

Summary

The 416 Range Not Satisfiable status code is an important component of HTTP range requests, providing clear feedback when a client requests portions of a resource that cannot be satisfied. This status code helps clients understand that their range request was understood but cannot be fulfilled, allowing them to adjust their request parameters accordingly. Range requests are particularly valuable for resuming downloads, streaming media, or accessing specific portions of large files, and the 416 status code ensures that clients can handle edge cases appropriately when requesting ranges.