sgl-project/sglang · info

Including the scheme in --host ('{host}') is deprecated. Pas

Error message

Including the scheme in --host ('{host}') is deprecated. Pass just the hostname (e.g. '127.0.0.1') instead.

What it means

In sglang/test_utils-style helpers, normalize_base_url warns with DeprecationWarning when the host string starts with http:// or https://. The function now expects a bare hostname; including the scheme changes URL semantics (double scheme in constructed URLs) so callers must pass just the host and the scheme is added by the caller/URL builder.

Source

Thrown at python/sglang/utils.py:166

    with open(filename, mode) as fout:
        for i, s in enumerate(states):
            if isinstance(s, str):
                pass
            elif isinstance(s, ProgramState):
                s = s.text()
            else:
                s = str(s)

            fout.write(
                "=" * 40 + f" {i} " + "=" * 40 + "\n" + s + "\n" + "=" * 80 + "\n\n"
            )


def normalize_base_url(host: str, port: int) -> str:
    from sglang.srt.utils.network import NetworkAddress

    if host.startswith("http://") or host.startswith("https://"):
        warnings.warn(
            f"Including the scheme in --host ('{host}') is deprecated. "
            f"Pass just the hostname (e.g. '127.0.0.1') instead.",
            DeprecationWarning,
            stacklevel=2,
        )
        return f"{host}:{port}"
    return NetworkAddress(host, port).to_url()


class HttpResponse:
    def __init__(self, resp):
        self.resp = resp

    @cached_property
    def _body(self):
        return self.resp.read()

    def json(self):

View on GitHub (pinned to 0132848349)

Solutions

  1. Pass the bare hostname: normalize_base_url('127.0.0.1', port) instead of 'http://127.0.0.1'
  2. If you need a full URL afterwards, build it explicitly: f"http://{normalize_base_url(host, port)}/health"
  3. grep test/eval scripts for 'http://' inside host arguments

Example fix

# before
base = normalize_base_url("http://127.0.0.1", 30000)
# after
base = normalize_base_url("127.0.0.1", 30000)
url = f"http://{base}/health"
Defensive patterns

Strategy: validation

Validate before calling

host = host.removeprefix("https://").removeprefix("http://")
base = normalize_base_url(host, port)

Type guard

def is_bare_host(h: str) -> bool: return not (h.startswith("http://") or h.startswith("https://"))

Prevention

When it happens

Trigger: Calling normalize_base_url(host="http://127.0.0.1", port=30000) (or https). Used by test helpers (test_concurrent, test_streaming), run_eval, select_sglang_backend, and ipv4/ipv6 host tests — so any of these with a scheme-prefixed --host triggers it.

Common situations: Copy-pasting a full URL from a browser/curl into --host; test scripts or eval harnesses written against an older signature that accepted schemes; IPv6 hosts like http://::1.

Related errors


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