{"record":{"id":"a5aee8994892d045","repo":"remotion-dev/remotion","slug":"server-returned-status-code-res-status-for-re","errorCode":null,"errorMessage":"Server returned status code ${res.status} for ${resolvedUrl} and range ${requestedRange}","messagePattern":"Server returned status code (.+?) for (.+?) and range (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/media-parser/src/readers/from-fetch.ts","lineNumber":156,"sourceCode":"\t\t\t\t\t\tRange: `bytes=${requestedRange}-`,\n\t\t\t\t\t}\n\t\t\t\t: {\n\t\t\t\t\t\tRange: `bytes=${`${requestedRange[0]}-${requestedRange[1]}`}`,\n\t\t\t\t\t};\n\n\tconst res = await fetch(resolvedUrl, {\n\t\theaders,\n\t\tsignal: ownController.signal,\n\t\tcache,\n\t});\n\n\tconst contentRange = res.headers.get('content-range');\n\tconst parsedContentRange = contentRange\n\t\t? parseContentRange(contentRange)\n\t\t: null;\n\n\tif (!res.ok) {\n\t\tthrow new Error(\n\t\t\t`Server returned status code ${res.status} for ${resolvedUrl} and range ${requestedRange}`,\n\t\t);\n\t}\n\n\tconst {supportsContentRange} = validateContentRangeAndDetectIfSupported({\n\t\trequestedRange,\n\t\tparsedContentRange,\n\t\tstatusCode: res.status,\n\t});\n\n\tif (controller) {\n\t\tcontroller._internals.signal.addEventListener(\n\t\t\t'abort',\n\t\t\t() => {\n\t\t\t\townController.abort(new MediaParserAbortError('Aborted by user'));\n\t\t\t},\n\t\t\t{once: true},\n\t\t);","sourceCodeStart":138,"sourceCodeEnd":174,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/media-parser/src/readers/from-fetch.ts#L138-L174","documentation":"In makeFetchRequest, after the fetch resolves the parser checks res.ok; any non-2xx status throws with the status code, URL, and requested range. This surfaces HTTP-level failures (404, 403, 500, etc.) before the parser tries to interpret bytes.","triggerScenarios":"The media URL returns a non-2xx HTTP status: 404 (wrong URL / asset removed), 403 (auth/permissions, expired presigned URL), 401 (auth required), 5xx (server error), or 429 (rate limited).","commonSituations":"Expired S3 presigned URLs, wrong/deleted asset paths, missing auth headers, CORS-preFlight failures surfacing as opaque errors, CDN origin errors, rate limiting, or hotlink protection blocking the request.","solutions":["Open the URL in a browser / curl `-I` to see the exact status and fix the root cause (404 -> correct path, 403 -> refresh credentials).","For presigned URLs, regenerate with a longer expiry before parsing.","Ensure any required auth/cookie headers are present and that CORS allows your origin.","Retry with backoff for transient 5xx/429, and surface a clear error to the end user."],"exampleFix":"// before\nawait parseMedia({src: presignedUrl, fields: {durationInSeconds: true}});\n\n// after: refresh presigned URL and handle status\nconst url = await getFreshPresignedUrl(key); // TTL-aware\ntry {\n  await parseMedia({src: url, fields: {durationInSeconds: true}});\n} catch (e) {\n  if (/status code 40[13]/.test(e.message)) throw new Error('Media URL expired or forbidden');\n  throw e;\n}","handlingStrategy":"retry","validationCode":"// HEAD-check the URL before parsing\nconst head = await fetch(url, {method: 'HEAD'});\nif (!head.ok) throw new Error(`Media URL returned ${head.status}`);","typeGuard":null,"tryCatchPattern":"async function withRetry<T>(fn: () => Promise<T>, retries = 3): Promise<T> {\n  for (let i = 0; i < retries; i++) {\n    try { return await fn(); }\n    catch (e) {\n      const m = e instanceof Error ? e.message : '';\n      if (/status code 5\\d\\d|429/.test(m) && i < retries - 1) {\n        await new Promise(r => setTimeout(r, 2 ** i * 500)); continue;\n      }\n      throw e;\n    }\n  }\n  throw new Error('unreachable');\n}\nawait withRetry(() => parseMedia({src: url, fields: {durationInSeconds: true}}));","preventionTips":["Refresh presigned URLs close to parse time; do not cache them long.","Verify URLs with curl -I before parsing.","Ensure CORS and auth headers are set for your origin.","Retry transient 5xx/429 with backoff; surface 4xx as user errors."],"tags":["network","http-status","auth","cdn","media-parser"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}