{"record":{"id":"4c50c980a7a57ee7","repo":"BerriAI/litellm","slug":"failed-to-bind-listener","errorCode":null,"errorMessage":"failed to bind listener","messagePattern":"failed to bind listener","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"litellm-rust/crates/ai-gateway/src/main.rs","lineNumber":82,"sourceCode":"    } else {\n        eprintln!(\n            \"realtime connection pool disabled (REALTIME_POOL_SIZE=0); fresh-dialing each connect\"\n        );\n    }\n\n    let state = AppState {\n        router,\n        master_key,\n        loggers: Arc::new(loggers),\n        realtime_pool,\n    };\n\n    let host = std::env::var(\"HOST\").unwrap_or_else(|_| DEFAULT_HOST.to_string());\n    let port = resolve_port();\n\n    let listener = tokio::net::TcpListener::bind((host.as_str(), port))\n        .await\n        .expect(\"failed to bind listener\");\n    eprintln!(\"litellm-ai-gateway listening on {host}:{port}\");\n    axum::serve(listener, routes::app(state))\n        .await\n        .expect(\"server error\");\n}\n\n/// Register every deployment's upstream key with the pool so the replenisher\n/// pre-warms it. Mirrors `service::run`'s key derivation (strip `openai/`, resolve\n/// api_key); deployments whose key can't be resolved are skipped (they fresh-dial\n/// and surface the auth error on the request path, as before).\nfn register_deployments(router: &Router, pool: &RealtimePool) {\n    for deployment in router.deployments() {\n        let params = &deployment.litellm_params;\n        let provider_model = params\n            .model\n            .strip_prefix(\"openai/\")\n            .unwrap_or(&params.model);\n        if let Some(key) = upstream_key(","sourceCodeStart":64,"sourceCodeEnd":100,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm-rust/crates/ai-gateway/src/main.rs#L64-L100","documentation":"Error \"failed to bind listener\" thrown in BerriAI/litellm.","triggerScenarios":"Thrown at litellm-rust/crates/ai-gateway/src/main.rs:82 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the bind address/port is free (not already in use) and the process has permission to bind it.","Change the listen address/port in configuration if it conflicts."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}