sgl-project/sglang · error · ValueError

received IPv6 address format: expected ':' after ']'

Error message

received IPv6 address format: expected ':' after ']'

What it means

Thrown by configure_ipv6 when text follows the closing ']' but the next character is not ':', so no port separator exists. The expected format is [ipv6]:port.

Source

Thrown at python/sglang/multimodal_gen/runtime/utils/common.py:177

def configure_ipv6(dist_init_addr):
    addr = dist_init_addr
    end = addr.find("]")
    if end == -1:
        raise ValueError("invalid IPv6 address format: missing ']'")

    host = addr[: end + 1]

    # this only validates the address without brackets: we still need the below checks.
    # if it's invalid, immediately raise an error so we know it's not formatting issues.
    if not is_valid_ipv6_address(host[1:end]):
        raise ValueError(f"invalid IPv6 address: {host}")

    port_str = None
    if len(addr) > end + 1:
        if addr[end + 1] == ":":
            port_str = addr[end + 2 :]
        else:
            raise ValueError("received IPv6 address format: expected ':' after ']'")

    if not port_str:
        raise ValueError(
            "a port must be specified in IPv6 address (format: [ipv6]:port)"
        )

    try:
        port = int(port_str)
    except ValueError:
        raise ValueError(f"invalid port in IPv6 address: '{port_str}'")
    return port, host


def is_port_available(port):
    """Return whether a port is available."""
    with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
        try:
            s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)

View on GitHub (pinned to 0132848349)

Solutions

  1. Put the port directly after a colon: "[fe80::1]:29500"
  2. Remove any path, slash, or stray characters after the bracket

Example fix

# before
addr = "[fe80::1]/29500"
# after
addr = "[fe80::1]:29500"
Defensive patterns

Strategy: validation

Validate before calling

end = addr.index("]")
assert len(addr) == end + 1 or addr[end + 1] == ":", "expected ':' after ']'"

Prevention

When it happens

Trigger: Passing "[fe80::1]/29500" or "[fe80::1]29500" — anything after ']' that doesn't start with ':'.

Common situations: Typos, or addresses copied with a slash/extra characters after the bracket; URL-style formatting applied where host:port is expected.

Related errors


AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28). Data as JSON: /api/errors/c505e792ff8e1a98. Report an issue: GitHub.