{"record":{"id":"f25fc1a1aa69e0df","repo":"sgl-project/sglang","slug":"a-port-must-be-specified-in-ipv6-address-format","errorCode":null,"errorMessage":"a port must be specified in IPv6 address (format: [ipv6]:port)","messagePattern":"a port must be specified in IPv6 address \\(format: \\[ipv6\\]:port\\)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/runtime/utils/common.py","lineNumber":180,"sourceCode":"    if end == -1:\n        raise ValueError(\"invalid IPv6 address format: missing ']'\")\n\n    host = addr[: end + 1]\n\n    # this only validates the address without brackets: we still need the below checks.\n    # if it's invalid, immediately raise an error so we know it's not formatting issues.\n    if not is_valid_ipv6_address(host[1:end]):\n        raise ValueError(f\"invalid IPv6 address: {host}\")\n\n    port_str = None\n    if len(addr) > end + 1:\n        if addr[end + 1] == \":\":\n            port_str = addr[end + 2 :]\n        else:\n            raise ValueError(\"received IPv6 address format: expected ':' after ']'\")\n\n    if not port_str:\n        raise ValueError(\n            \"a port must be specified in IPv6 address (format: [ipv6]:port)\"\n        )\n\n    try:\n        port = int(port_str)\n    except ValueError:\n        raise ValueError(f\"invalid port in IPv6 address: '{port_str}'\")\n    return port, host\n\n\ndef is_port_available(port):\n    \"\"\"Return whether a port is available.\"\"\"\n    with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:\n        try:\n            s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)\n            s.bind((\"\", port))\n            s.listen(1)\n            return True","sourceCodeStart":162,"sourceCodeEnd":198,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/utils/common.py#L162-L198","documentation":"Thrown by configure_ipv6 when the string ends at ']' or the ':' is present but the port substring is empty — distributed init over IPv6 requires an explicit port.","triggerScenarios":"Passing \"[fe80::1]\" or \"[fe80::1]:\" as dist_init_addr.","commonSituations":"Only the address was templated into the config and the port variable was empty; user assumed a default port exists.","solutions":["Append an explicit port: \"[fe80::1]:29500\"","Check that the port variable in your launch script/config is set"],"exampleFix":"# before\naddr = \"[fe80::1]:\"\n# after\naddr = \"[fe80::1]:29500\"","handlingStrategy":"validation","validationCode":"end = addr.index(\"]\")\nassert len(addr) > end + 2 and addr[end + 2:].strip(), \"port required after [ipv6]:\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never leave the port side of an address template empty; assert on it in launch scripts"],"tags":["ipv6","distributed","network","port","validation"],"backgroundTag":"invalid-ipv6-address","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}