{"record":{"id":"b56f33cc32ac0851","repo":"denoland/deno","slug":"cannot-specify-two-ipv6-addresses","errorCode":null,"errorMessage":"Cannot specify two IPv6 addresses","messagePattern":"Cannot specify two IPv6 addresses","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"ext/node/polyfills/internal_binding/cares_wrap.ts","lineNumber":936,"sourceCode":"    // stored value is not applied to outgoing queries; see\n    // https://github.com/denoland/deno/issues/36518.\n    let type0: 4 | 6;\n    if (isIPv4(addr0)) {\n      type0 = 4;\n    } else if (isIPv6(addr0)) {\n      type0 = 6;\n    } else {\n      throw new Error(`Invalid IP address: ${addr0}`);\n    }\n\n    if (addr1 !== undefined) {\n      if (isIPv4(addr1)) {\n        if (type0 === 4) {\n          throw new Error(\"Cannot specify two IPv4 addresses\");\n        }\n      } else if (isIPv6(addr1)) {\n        if (type0 === 6) {\n          throw new Error(\"Cannot specify two IPv6 addresses\");\n        }\n      } else {\n        throw new Error(`Invalid IP address: ${addr1}`);\n      }\n    }\n\n    this.#localAddress = {\n      ipv4: type0 === 4 ? addr0 : addr1,\n      ipv6: type0 === 6 ? addr0 : addr1,\n    };\n  }\n\n  cancel() {\n    for (const req of new SafeSetIterator(this.#pendingQueries)) {\n      req.oncomplete(\"ECANCELLED\", []);\n    }\n    SetPrototypeClear(this.#pendingQueries);\n","sourceCodeStart":918,"sourceCodeEnd":954,"githubUrl":"https://github.com/denoland/deno/blob/a961cdec3b1948844414ebeecc697dcad76df2d1/ext/node/polyfills/internal_binding/cares_wrap.ts#L918-L954","documentation":"Analogous to the IPv4 case: ChannelWrap accepts at most one local address per address family. If both addr0 and addr1 are valid IPv6 literals, this error is thrown because the pair cannot be mapped onto the single ipv4/ipv6 slot structure used for c-ares.","triggerScenarios":"Calling a ChannelWrap lookup with two local addresses where addr0 is IPv6 and addr1 is also an IPv6 literal (e.g. '::' and '::1').","commonSituations":"Misconfigured multi-homed setups passing two IPv6 interface addresses as localAddress/localAddresses; scripts that iterate over all interface addresses and pass them all through.","solutions":["Pass one IPv6 and one IPv4 address, not two IPv6 addresses.","Filter the address list so only the first address of each family is used.","Remove the redundant IPv6 address from the localAddress options."],"exampleFix":"// before\nnew ChannelWrap('::1', 'fe80::1'); // two IPv6\n// after\nnew ChannelWrap('::1', '0.0.0.0'); // one IPv6 + one IPv4","handlingStrategy":"validation","validationCode":"if (isIPv6(addr0) && isIPv6(addr1)) {\n  throw new Error('Provide at most one IPv6 local address');\n}","typeGuard":"function atMostOneIpv6(a, b) {\n  return !(b !== undefined && isIPv6(a) && isIPv6(b));\n}","tryCatchPattern":"try {\n  channel.lookup(req, hostname);\n} catch (err) {\n  if (err.message === 'Cannot specify two IPv6 addresses') {\n    // drop the second IPv6 address and retry\n  }\n}","preventionTips":["Filter interface address lists to the first address per family.","Normalize config so localAddresses is always [ipv4?, ipv6?] in that order.","Unit-test address-pair assembly from multi-NIC configurations."],"tags":["dns","node-compat","validation"],"backgroundTag":"invalid-ip-address","analyzedSha":"a961cdec3b1948844414ebeecc697dcad76df2d1","analyzedAt":"2026-09-03T14:18:07.398Z","contentChangedAt":"2026-09-03T14:18:07.398Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}