sgl-project/sglang · error · ValueError
--enable-http2 requires the 'granian' package. Install it wi
Error message
--enable-http2 requires the 'granian' package. Install it with: pip install "sglang[http2]"
What it means
HTTP/2 serving in SGLang is backed by the granian web server, which is an optional dependency. This error is raised when --enable-http2 is used but the granian package is not installed in the environment.
Source
Thrown at python/sglang/srt/server_args.py:4358
f"Please check the --ssl-ca-certs path."
)
if cfg.enable_ssl_refresh and not (cfg.ssl_certfile and cfg.ssl_keyfile):
raise ValueError(
"--enable-ssl-refresh requires --ssl-certfile and --ssl-keyfile "
"to be specified."
)
if cfg.enable_http2:
if not 0 < cfg.http2_max_concurrent_streams < 2**32:
raise ValueError(
"--http2-max-concurrent-streams must be between 1 and "
"4294967295."
)
try:
import granian # noqa: F401
except ImportError:
raise ValueError(
"--enable-http2 requires the 'granian' package. "
'Install it with: pip install "sglang[http2]"'
)
if cfg.enable_ssl_refresh:
raise ValueError(
"--enable-ssl-refresh is not supported with --enable-http2. "
"Granian does not support SSL certificate hot-reloading. "
"Use Uvicorn (the default) or handle certificate rotation externally."
)
def _handle_multimodal(self):
"""Validate mm_process_config structure before model loading."""
cfg = resolving_view(self)
if (
cfg.mm_preprocess_cache_size_mb is not None
and cfg.mm_preprocess_cache_size_mb < 0
):View on GitHub (pinned to 0132848349)
Solutions
- Install the extra: pip install "sglang[http2]"
- Or install granian directly: pip install granian
- Or drop --enable-http2 to use the default Uvicorn HTTP/1.1 server
Example fix
# before pip install sglang python -m sglang.launch_server --enable-http2 # after pip install "sglang[http2]" python -m sglang.launch_server --enable-http2
Defensive patterns
Strategy: type-guard
Validate before calling
try:
import granian # noqa
except ImportError:
raise SystemExit('pip install "sglang[http2]"') Type guard
def has_http2_support() -> bool:
try:
import granian # noqa
return True
except ImportError:
return False Prevention
- Pin extras in requirements: sglang[http2]
- Add import checks to Docker build smoke tests
When it happens
Trigger: Starting the server with --enable-http2 in an environment where 'import granian' fails (base sglang install without the http2 extra).
Common situations: Installing sglang via a minimal/base pip install or Docker image that omits extras; upgrading sglang in an old venv that predates the granian extra.
Related errors
- --http2-max-concurrent-streams must be between 1 and 4294967
- Cannot find NVIDIA Math-DX (cuBLASDx) headers. Install the `
- Cannot find CUTLASS headers required for JIT compilation. Pl
- FlashAttention-4 CUTE is not available. Install flash-attn-4
- FlashAttention-4 CUTE is not available. Install flash-attn-4
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/8e4cda3a01427c29.
Report an issue: GitHub.