{"record":{"id":"7f27b125a31623c6","repo":"denoland/deno","slug":"err-out-of-range","errorCode":"ERR_OUT_OF_RANGE","errorMessage":"The value of \"headersTimeout\" is out of range. It must be <= requestTimeout. Received ${headersTimeout}","messagePattern":"The value of \"headersTimeout\" is out of range\\. It must be <= requestTimeout\\. Received (.+?)","errorType":"exception","errorClass":"NodeRangeError","httpStatus":null,"severity":"error","filePath":"ext/node/polyfills/_http_server.js","lineNumber":1485,"sourceCode":"    validateInteger(requestTimeout, \"requestTimeout\", 0);\n    this.requestTimeout = requestTimeout;\n  } else {\n    this.requestTimeout = 300_000; // 5 minutes\n  }\n\n  const headersTimeout = options.headersTimeout;\n  if (headersTimeout !== undefined) {\n    validateInteger(headersTimeout, \"headersTimeout\", 0);\n    this.headersTimeout = headersTimeout;\n  } else {\n    this.headersTimeout = MathMin(60_000, this.requestTimeout);\n  }\n\n  if (\n    this.requestTimeout > 0 && this.headersTimeout > 0 &&\n    this.headersTimeout > this.requestTimeout\n  ) {\n    throw new ERR_OUT_OF_RANGE(\n      \"headersTimeout\",\n      \"<= requestTimeout\",\n      headersTimeout,\n    );\n  }\n\n  const keepAliveTimeout = options.keepAliveTimeout;\n  if (keepAliveTimeout !== undefined) {\n    validateInteger(keepAliveTimeout, \"keepAliveTimeout\", 0);\n    this.keepAliveTimeout = keepAliveTimeout;\n  } else {\n    this.keepAliveTimeout = 5_000;\n  }\n\n  const connectionsCheckingInterval = options.connectionsCheckingInterval;\n  if (connectionsCheckingInterval !== undefined) {\n    validateInteger(\n      connectionsCheckingInterval,","sourceCodeStart":1467,"sourceCodeEnd":1503,"githubUrl":"https://github.com/denoland/deno/blob/89f33cbef296a2b287f323d42de54c871fa69c77/ext/node/polyfills/_http_server.js#L1467-L1503","documentation":"When the HTTP server is constructed, headersTimeout defaults to min(60000, requestTimeout); an explicit value is validated as a non-negative integer and then cross-checked: when both requestTimeout and headersTimeout are positive, headersTimeout must not exceed requestTimeout, otherwise ERR_OUT_OF_RANGE is thrown. The header-reading phase cannot be allowed to outlive the whole request deadline.","triggerScenarios":"new http.Server({ requestTimeout: 3000, headersTimeout: 10000 }) or http.createServer with any options where 0 < requestTimeout < headersTimeout; the check runs in the constructor, so creation itself fails.","commonSituations":"Tuning server timeouts via config/env where the knobs are set independently; lowering requestTimeout for DoS protection while leaving a large headersTimeout; copying timeout numbers between Node versions whose defaults differed.","solutions":["Set headersTimeout <= requestTimeout, or omit it and accept the default min(60000, requestTimeout)","If you need a larger headersTimeout, raise requestTimeout to at least that value","Centralize timeout config and assert the invariant at startup","Remember both are milliseconds and 0 disables the respective timeout"],"exampleFix":"// before\nconst server = http.createServer({ requestTimeout: 3_000, headersTimeout: 10_000 }, handler); // throws\n\n// after\nconst server = http.createServer({ requestTimeout: 10_000, headersTimeout: 10_000 }, handler);","handlingStrategy":"validation","validationCode":"function normalizeTimeouts(o) {\n  const rt = o.requestTimeout ?? 300_000;\n  const ht = o.headersTimeout ?? Math.min(60_000, rt);\n  if (rt > 0 && ht > 0 && ht > rt) {\n    o.headersTimeout = rt; // clamp: header phase cannot exceed the request deadline\n  }\n  return o;\n}\nconst server = http.createServer(normalizeTimeouts(opts), handler);","typeGuard":null,"tryCatchPattern":"try {\n  server = http.createServer(opts, handler);\n} catch (e) {\n  if (e.code === 'ERR_OUT_OF_RANGE' && /headersTimeout/.test(e.message)) {\n    const { headersTimeout, ...rest } = opts;\n    server = http.createServer(rest, handler); // fall back to the default\n  } else throw e;\n}","preventionTips":["Derive headersTimeout from requestTimeout in one config helper","Assert timeout invariants in a startup smoke test","Remember both values are milliseconds and 0 disables the timeout"],"tags":["http","configuration","timeouts","node-compat"],"backgroundTag":null,"analyzedSha":"89f33cbef296a2b287f323d42de54c871fa69c77","analyzedAt":"2026-08-16T07:54:21.310Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}