sgl-project/sglang · error · ValueError

{field_name} must include both host and port: {value!r}

Error message

{field_name} must include both host and port: {value!r}

What it means

Thrown by parse_tcp_host_port when the string splits on ':' but either the host or the port side is empty after stripping (e.g. ":5555" or "host:"). Both parts are required.

Source

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

def parse_tcp_host_port(value: str | None, field_name: str) -> tuple[str, int]:
    if value is None or not str(value).strip():
        raise ValueError(f"{field_name} is required")

    addr = str(value).strip()
    if addr.startswith("tcp://"):
        addr = addr[len("tcp://") :]

    try:
        host, port_str = addr.rsplit(":", 1)
    except ValueError as exc:
        raise ValueError(
            f"{field_name} must be formatted as tcp://host:port or host:port"
        ) from exc

    host = host.strip()
    port_str = port_str.strip()
    if not host or not port_str:
        raise ValueError(f"{field_name} must include both host and port: {value!r}")

    try:
        port = int(port_str)
    except ValueError as exc:
        raise ValueError(f"{field_name} port must be an integer: {port_str}") from exc

    if port < 0 or port > 65535:
        raise ValueError(f"{field_name} port must be between 0 and 65535: {port}")
    return host, port


def format_tcp_endpoint(host: str, port: int, field_name: str) -> str:
    if port < 0 or port > 65535:
        raise ValueError(f"{field_name} port must be between 0 and 65535: {port}")
    return f"tcp://{host}:{port}"


def configure_ipv6(dist_init_addr):

View on GitHub (pinned to 0132848349)

Solutions

  1. Fill in both host and port in the endpoint string
  2. Check template/format-string interpolation that builds the endpoint for empty variables

Example fix

# before
endpoint = f"{host}:"  # port unset
# after
endpoint = f"{host}:{port}"
Defensive patterns

Strategy: validation

Validate before calling

v = endpoint.removeprefix("tcp://")
host, _, port = v.rpartition(":")
assert host.strip() and port.strip(), "both host and port required"

Prevention

When it happens

Trigger: Passing ":9000" (no host), "127.0.0.1:" (no port), or " : " to parse_tcp_host_port.

Common situations: Default placeholder like "{host}:{port}" with one variable unfilled; trailing colon from string concatenation where the port variable was empty.

Related errors


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