
Why Your S3 Video Plays but Won’t Seek: Debug Range Requests Through CloudFront
Debug an S3 MP4 that plays but won’t seek. Use curl and a local fixture to compare 206 and 200 responses, then trace CloudFront and S3.
A video starts, but dragging the playhead past the buffered section leaves it spinning. For a progressive MP4 served from Amazon S3 through Amazon CloudFront, start with the network request that stalled. Find out whether the player asked for a slice of the object and what bytes came back. That separates a delivery problem from a player that already has the bytes it needs.
Read one seek request before changing settings
Open DevTools → Network, enable Preserve log and Disable cache while DevTools is open, then reload. Start playback and seek to a point that has yet to buffer. Search for the actual MP4 URL or object path. A player that fetches through JavaScript can put the request under Fetch/XHR, so keep All selected if the Media filter shows nothing. Open the request tied to the seek and record its method, URL, request
Range (and If-Range , if present), response status, Content-Range and any Content-Encoding . Record the request time so you can match it to logs. Chrome DevTools network reference Run a separate control GET against the same CloudFront URL, preserving the authorization needed for that URL. Replace the example host and use an authorized test object of known size. Keep signed query strings and cookies out of shared logs. Run this in a fresh scratch directory. The command saves the response body separately and limits the transfer. Use curl 8.4 or later if the response might omit its size. A large full response may trigger the size or time limit, in which case inspect the saved headers and discard the incomplete body. curl transfer limits
url='https://media.example.com/video.mp4'curl -q -sS --max-time 15 --max-filesize 1048576 \ -H 'Range: bytes=0-1023' -H 'Accept-Encoding: identity' \ -D cloudfront.headers -o cloudfront.body "$url" && wc -c < cloudfront.bodygrep -Ei '^(HTTP/|content-range:|content-length:|content-type:|content-encoding:|x-cache:)' cloudfront.headers- 206 Partial Content with
Content-Range: bytes 0-1023/Nand 1,024 saved bytes confirms the response covers that interval for a representation at least 1,024 bytes long.Nis its total size and byte positions are zero-based and inclusive. A small object can validly end the interval earlier. When comparing encoded and unencoded responses, remember that byte positions refer to the encoded representation actually served.
- 200 OK with the complete MP4 means the range did not determine the body of that response. First verify the request carried
Rangeand the response was the MP4 rather than a login or fallback page. A browser'sIf-Rangecondition can also explain a full response when its validator fails to match.
- 416 Range Not Satisfiable with
Content-Range: bytes */Ngives you a size to compare with the requested start. If the start is past the end and the player expected a different size, check whether the media URL now resolves to a different object version.
Accept-Ranges: bytes advertises support. Use the status, Content-Range and actual payload of a GET to see how this request was handled. If the first kilobyte works, repeat the probe for the seek offset seen in DevTools. If no request carries a range, first check whether the player already buffered the target or whether it uses a different delivery path, such as an HLS playlist and segment URLs. HTTP Semantics, Range Requests Reproduce the two responses locally
The following server serves four distinct 1,024-byte blocks.
/partial handles a single closed range such as bytes=0-1023 . /full sends the complete object for the same request. The data is synthetic, and the exercise tests HTTP behavior on loopback. It uses no AWS resources and does not test browser playback. Save the script as range_fixture.py and run python3 range_fixture.py in one terminal."""Serve four distinct blocks on loopback for a byte-range exercise."""import refrom http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
OBJECT = b"A" * 1024 + b"B" * 1024 + b"C" * 1024 + b"D" * 1024
class RangeFixture(BaseHTTPRequestHandler): def do_GET(self): if self.path not in ("/partial", "/full"): self.send_error(404) return
header = self.headers.get("Range", "") match = re.fullmatch(r"bytes=([0-9]{1,12})-([0-9]{1,12})", header) if self.path == "/full" or not match: self.reply(200, OBJECT) return
first, last = map(int, match.groups()) if first > last: self.reply(200, OBJECT) elif first >= len(OBJECT): self.reply(416, b"", f"bytes */{len(OBJECT)}") else: last = min(last, len(OBJECT) - 1) self.reply(206, OBJECT[first:last + 1], f"bytes {first}-{last}/{len(OBJECT)}")
def reply(self, status, body, content_range=None): self.send_response(status) self.send_header("Content-Type", "application/octet-stream") self.send_header("Content-Length", str(len(body))) if content_range is not None: self.send_header("Content-Range", content_range) self.end_headers() self.wfile.write(body)
def log_message(self, *args): pass
if __name__ == "__main__": with ThreadingHTTPServer(("127.0.0.1", 8765), RangeFixture) as server: print("Listening on 127.0.0.1:8765", flush=True) server.serve_forever()Run the following in a scratch directory in a second terminal.
for endpoint in partial full; do curl -q --noproxy '*' -sS --max-time 5 \ -H 'Range: bytes=0-1023' \ -D "$endpoint.headers" -o "$endpoint.body" \ "http://127.0.0.1:8765/$endpoint" || break grep -Ei '^(HTTP/|content-range:|content-length:)' "$endpoint.headers" wc -c < "$endpoint.body"donepython3 - <<'PY'from pathlib import Path
partial = Path("partial.body").read_bytes()full = Path("full.body").read_bytes()if partial != b"A" * 1024 or partial != full[:1024] or len(full) != 4096: raise SystemExit("unexpected response bodies")print("The partial response contains exactly the first 1,024 bytes.")PYThe local run produced these results. An additional probe for bytes 2048–3071 verified that the body contained exactly 1,024
C bytes, which would catch a server that always sends the first block. A start at 4096 returned 416 and an empty body./partial | bytes=0-1023 | 206 | bytes 0-1023/4096 | 1024 bytes, content verified/full | bytes=0-1023 | 200 | (none) | 4096 bytes, content verified/partial | bytes=2048-3071 | 206 | bytes 2048-3071/4096 | 1024 bytes, content verified/partial | bytes=4096-5119 | 416 | bytes */4096 | 0 bytes, content verified/partial | (no Range) | 200 | (none) | 4096 bytes, content verifiedFollow the same object through CloudFront and S3
- Check which cache behavior served the path. On a cache miss, CloudFront can ask the origin for a larger byte range than the viewer requested. If an edge already holds the requested bytes, including as part of a cached whole object, CloudFront can return
206without contacting the origin. An origin that ignores ranges can therefore produce a full response on the first request while a later viewer request gets a slice from cache. Disabling the browser cache does not clear the edge cache. If you already have CloudFront logs, correlate by path, time and edge result to separate those cases. CloudFront range GET behavior , CloudFront standard logs
- Compare against S3 using authorized access. S3 supports one range per
GetObjectrequest. If you have read access, use the AWS CLI with the bucket and key that back the viewer URL. Keep the bucket private. If objects have been replaced, establish that you are comparing the same object version and content encoding before comparing the byte count or payload. A403or404is a separate authorization or object-path check. Amazon S3 GetObject API , AWS CLI ranged download
- Inspect the origin response if the two paths disagree. A correct S3 response alongside a CloudFront
200warrants checking the matching origin and anything that handles the request or response between the viewer and S3. AWS documents a full response for malformed range sets such as overlapping or out-of-order intervals. It also documents a full viewer response when the origin returnsTransfer-Encoding: chunkedfor a range GET. This is a statement about the origin response. A viewer-side header alone cannot establish what CloudFront received upstream. CloudFront range GET behavior
This read-only AWS CLI example assumes you set
S3_BUCKET and S3_KEY and have credentials for the object. Run it in a scratch directory.aws s3api get-object --bucket "$S3_BUCKET" --key "$S3_KEY" \ --range 'bytes=0-1023' --query '[ContentRange,ContentLength]' \ s3-range.body && wc -c < s3-range.bodyIf the seek offset gets a good 206, inspect the player
A valid range response confirms byte delivery for the interval you tested. In Chrome’s Media panel, inspect the player’s events and messages at the point the seek stalls. If the same MP4 reproduces the issue in a plain video element, inspect the file’s container and codecs. If only the application player stalls, investigate how it chooses and buffers data after a seek. No new request may be expected if the target is already buffered. Chrome DevTools Media panel
For a non-fragmented MP4, check where the
moov metadata sits. FFmpeg’s faststart option moves the metadata to the beginning of the file, which can help a player read it earlier. Treat a remux as a separate test and check playback again. It does not repair a missing range response or change codec compatibility. FFmpeg MP4 muxer documentation For a handoff, save the failed browser request and a control GET with the same offset. If they deliver the expected bytes, include the player’s error or buffering event. If they deliver the whole object, include the edge result and the authorized origin comparison. Those details give the next person a specific place to start.
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article