M3U8 request diagnosis starts by separating the request result from the content you receive. Use cURL to capture the response, then decide whether your next action concerns a connection failure, an HTTP refusal, a redirected reference or a playlist defect. The next resource to request might be a Media Playlist or a Media Segment; their URI lines have different meanings under RFC 8216.
Check which cURL you are running
Windows PowerShell 5.1 defines curl as an alias for Invoke-WebRequest. Invoke the native executable explicitly as curl.exe before trying cURL options; otherwise, you're addressing a different command. This distinction matters before you interpret a failure message, because the command name alone doesn't identify the program you're testing. Microsoft documents the alias.
Run curl.exe --version in that environment, or curl --version where you're invoking native cURL. The output displays the installed version and enabled features, giving you a concrete starting point for the capture. Keep that output alongside your request results so a later comparison concerns the executable you actually used. cURL documents the version output.
The capture below requires cURL 7.76.0 or later because it uses --fail-with-body. Check that prerequisite before copying the command, rather than treating an unavailable option as a problem with your M3U8 URL. If the executable rejects an option, resolve that command issue before drawing conclusions about the server's response. See the option's version requirement.
Windows batch files require doubled percent signs in --write-out formats. Interactive cmd.exe has different escaping limitations, so a batch-file example isn't a universal Windows command. The example below uses PowerShell syntax; if you're moving it into a batch file, adapt its write-out format for that context. The write-out documentation explains the Windows distinction.
If you're using Windows PowerShell 5.1, confirm the executable and version before continuing with the capture. Keep the version output with your results, where you can refer to it when interpreting the command.
M3U8 request diagnosis: save the response and bound the request
A useful capture keeps headers, downloaded content and request metadata distinguishable. The following PowerShell example uses illustrative filenames and limits: the timeout values and redirect count are example choices, not recommended defaults. Replace YOUR_M3U8_URL with the address you're investigating, then keep the resulting files together for inspection.
curl.exe -q --location --max-redirs 5 --connect-timeout 10 --max-time 30 --proto '=http,https' --proto-redir '=http,https' --fail-with-body --dump-header headers.txt --output response.txt --write-out 'HTTP %{http_code}\nURL %{url_effective}\n' 'YOUR_M3U8_URL'Keep -q as the first option: that position disables the default curlrc configuration. It's an explicit part of this example, rather than a flag to move freely while tidying the command. If you're comparing attempts, preserve that position so each invocation uses the same configuration choice. See cURL's configuration control.
--dump-header headers.txt saves received headers to the chosen file, while --output response.txt saves downloaded content instead of sending it to stdout. Open headers.txt to inspect headers and response.txt to inspect returned content. The neutral body filename avoids assuming that whatever the server returns is a playlist. Both file options are documented here.
--write-out reports separate metadata: %{http_code} is the last retrieved HTTP response code, and %{url_effective} is the last fetched URL. Keep both values with the saved files. The response code helps you interpret the server's answer, while the fetched address matters when following relative playlist references. See the write-out variables.
--location follows HTTP redirects to their Location targets; --max-redirs limits how many redirects cURL follows. The example permits five, making its redirect boundary explicit. If you're investigating a redirected address, retain the final URL printed by the command instead of assuming the address you entered remained the retrieval location. See redirect handling.
--connect-timeout covers connection establishment, including DNS lookup and TCP/TLS handshakes; --max-time still applies and limits transfer time in seconds. These are different boundaries, so the example's connection allowance doesn't replace its overall transfer limit. A timeout result needs interpretation before you change either setting. See the timeout options.
--proto '=http,https' restricts transfers to those schemes, while --proto-redir separately restricts redirect schemes. For an HTTP or HTTPS investigation, use both controls to make the permitted schemes explicit. With the capture saved, inspect its exit status and response before selecting another URL to request. See protocol restrictions.
Read the exit status separately from the HTTP response
PowerShell stores the last native program's exit code in $LASTEXITCODE. Read it immediately after the cURL invocation, before another native program changes which result it represents. That gives you the transfer's exit status alongside the HTTP metadata printed by the capture, so you can interpret each signal separately. Microsoft describes this automatic variable.
| Signal | Supported interpretation | Reader action |
|---|---|---|
| Exit 6 | Host resolution failed. | Classify the attempt as a resolution failure. |
| Exit 7 | Connection failed. | Classify the attempt as a connection failure. |
| Exit 28 | The operation timed out. | Record a timeout without assigning an underlying cause. |
| Exit 22 with --fail-with-body | An HTTP status of 400 or higher was returned. | Inspect the retained error body and recorded HTTP code. |
| HTTP 403 | The server understood but refused the request. | Don't assume credentials explain the refusal. |
| HTTP 404 | No current representation was found, or existence is undisclosed. | Don't assume the resource has permanently disappeared. |
The transport classifications come from cURL's exit-code definitions. With --fail-with-body, HTTP error content remains available despite the failure exit status. Open the body capture when you get that result: the failed invocation can still leave returned content for you to examine.
The HTTP definitions allow a 403 refusal for reasons unrelated to credentials, and a 404 can conceal a forbidden resource. Neither status gives you a complete explanation of the server's decision. Base your conclusion on the response you've received, and don't change credentials without evidence that they caused the failure.
If you have exit 6, 7 or 28, classify that transport result first; if you have an HTTP error, inspect its retained content before treating it as a playlist.
Follow playlist references from the final fetched URL
A Master Playlist leads you towards Media Playlists; a Media Playlist leads you towards Media Segments. That distinction determines what to request next, rather than treating every URI line as the same kind of resource. For a variant, #EXT-X-STREAM-INF describes the Variant Stream and the following URI line identifies its Media Playlist. RFC 8216 defines these relationships.
Relative references use the URI of their containing playlist. After redirects, absent an embedded or enclosing base URI, the retrieval base is the final retrieval URI. Apply those rules together: identify the playlist containing the reference, then use its retrieval address to resolve that reference. The URL initially entered isn't automatically the right base. HLS defines relative references, and RFC 3986 defines the retrieval base.
An illustrative redirected playlist
Suppose your request finishes at https://media.example/live/master.m3u8, with no embedded or enclosing base URI. These are illustrative URL calculations, not reported test results. In the retrieved Master Playlist, imagine that a #EXT-X-STREAM-INF tag is followed by variants/main.m3u8; that reference gives you the next playlist to request.
- Use
https://media.example/live/master.m3u8as the containing Master Playlist's base. - Resolve
variants/main.m3u8tohttps://media.example/live/variants/main.m3u8. - Request that Media Playlist, retaining its own final retrieval address.
- For this example, stipulate that its final address is unchanged and its segment reference is
chunks/001.ts. - Resolve that reference to
https://media.example/live/variants/chunks/001.ts.
The last calculation uses the Media Playlist's address, including its variants/ directory. Continuing to use the Master Playlist's directory would produce a different illustrative address, https://media.example/live/chunks/001.ts. Comparing those paths shows why identifying the containing playlist matters: the base changes as you move from the variant reference to its segment reference.
If the Media Playlist itself redirects, resolve its references from its own final retrieval URI under the same base-URI conditions. Don't carry the first playlist's location through the entire chain. Here, the intermediate playlist request supplies the address you need for the segment calculation; skipping it leaves you using the wrong context.
If you're holding a relative URI such as chunks/001.ts, find its containing playlist before constructing the next request. That keeps the request tied to the file where the reference actually appears.
Check the retrieved playlist's structure
#EXTM3U must be the first playlist line, but that check alone doesn't establish conformance. Inspect it as an opening requirement, rather than a verdict that every subsequent tag is correct. A response can pass this first check while still needing the specific structural checks below. RFC 8216 sets the identification requirement.
HLS playlists must use UTF-8 and must not contain a byte order mark. If you control the playlist, check its encoding and remove any byte order mark rather than inspecting only the visible tag text. This is a file-content requirement, so a recognisable opening line doesn't replace the encoding check. See the playlist encoding requirements.
Each segment requires #EXTINF, giving a duration expressed as an integer or a decimal floating-point number, a required comma and an optional title. An illustrative line is #EXTINF:6.2,: the empty title is permitted, while the comma remains required. Inspect each segment individually; a duration elsewhere in the file doesn't supply a missing segment tag. See the EXTINF definition.
Each Media Playlist also needs #EXT-X-TARGETDURATION. Every EXTINF duration, rounded to the nearest integer, must not exceed that target. With an illustrative target duration of 6, a duration of 6.2 rounds to 6 and meets this comparison; 6.8 rounds to 7 and exceeds it. Compare the rounded value rather than rejecting every decimal above the target. See the target-duration rule.
Master Playlist tags cannot mix with Media Playlist or Media Segment tags; RFC 8216 requires clients to fail parsing that mixture. If you control such a file, correct the mixed structure rather than treating successful retrieval as the end of the investigation. Receiving content and parsing its playlist structure are separate diagnostic questions. See the tag-mixing restriction.
These requirements were checked on 17 October 2026. If your retrieved file fails a check, identify that exact defect before changing unrelated settings; passing these checks doesn't promise playback or replace a complete validator.
Why does curl run Invoke-WebRequest in Windows PowerShell?
Windows PowerShell 5.1 defines curl as an alias for Invoke-WebRequest. Use curl.exe to invoke the native executable explicitly.
How do I keep the HTTP error body when cURL fails?
Use --fail-with-body with --output and a filename. Available since cURL 7.76.0, --fail-with-body retains HTTP error content while returning exit code 22 for HTTP status 400 or higher.
Does an M3U8 403 response mean my credentials are wrong?
No. HTTP 403 means the server understood but refuses the request. The reason can be unrelated to credentials, so the status alone doesn't identify the cause.
Which URL should I use for relative paths after a redirect?
Use the containing playlist's final retrieval URI when there is no embedded or enclosing base URI. Each subsequently retrieved playlist supplies the context for its own relative references.
Does #EXTM3U prove that my playlist is valid?
No. RFC 8216 requires #EXTM3U as the first playlist line, but meeting that requirement alone doesn't establish playlist conformance.
