{"record":{"id":"8e4cda3a01427c29","repo":"sgl-project/sglang","slug":"enable-http2-requires-the-granian-package-ins","errorCode":null,"errorMessage":"--enable-http2 requires the 'granian' package. Install it with: pip install \"sglang[http2]\"","messagePattern":"--enable-http2 requires the 'granian' package\\. Install it with: pip install \"sglang\\[http2\\]\"","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/server_args.py","lineNumber":4358,"sourceCode":"                f\"Please check the --ssl-ca-certs path.\"\n            )\n        if cfg.enable_ssl_refresh and not (cfg.ssl_certfile and cfg.ssl_keyfile):\n            raise ValueError(\n                \"--enable-ssl-refresh requires --ssl-certfile and --ssl-keyfile \"\n                \"to be specified.\"\n            )\n\n        if cfg.enable_http2:\n            if not 0 < cfg.http2_max_concurrent_streams < 2**32:\n                raise ValueError(\n                    \"--http2-max-concurrent-streams must be between 1 and \"\n                    \"4294967295.\"\n                )\n\n            try:\n                import granian  # noqa: F401\n            except ImportError:\n                raise ValueError(\n                    \"--enable-http2 requires the 'granian' package. \"\n                    'Install it with: pip install \"sglang[http2]\"'\n                )\n\n            if cfg.enable_ssl_refresh:\n                raise ValueError(\n                    \"--enable-ssl-refresh is not supported with --enable-http2. \"\n                    \"Granian does not support SSL certificate hot-reloading. \"\n                    \"Use Uvicorn (the default) or handle certificate rotation externally.\"\n                )\n\n    def _handle_multimodal(self):\n        \"\"\"Validate mm_process_config structure before model loading.\"\"\"\n        cfg = resolving_view(self)\n        if (\n            cfg.mm_preprocess_cache_size_mb is not None\n            and cfg.mm_preprocess_cache_size_mb < 0\n        ):","sourceCodeStart":4340,"sourceCodeEnd":4376,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/server_args.py#L4340-L4376","documentation":"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.","triggerScenarios":"Starting the server with --enable-http2 in an environment where 'import granian' fails (base sglang install without the http2 extra).","commonSituations":"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.","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"],"exampleFix":"# before\npip install sglang\npython -m sglang.launch_server --enable-http2\n# after\npip install \"sglang[http2]\"\npython -m sglang.launch_server --enable-http2","handlingStrategy":"type-guard","validationCode":"try:\n    import granian  # noqa\nexcept ImportError:\n    raise SystemExit('pip install \"sglang[http2]\"')","typeGuard":"def has_http2_support() -> bool:\n    try:\n        import granian  # noqa\n        return True\n    except ImportError:\n        return False","tryCatchPattern":null,"preventionTips":["Pin extras in requirements: sglang[http2]","Add import checks to Docker build smoke tests"],"tags":["http2","missing-dependency","pip","server-args"],"backgroundTag":"missing-optional-dependency","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}