{"record":{"id":"5b6d5f4a35f021c3","repo":"nautechsystems/nautilus_trader","slug":"failed-to-connect-to-databento-lsg-e","errorCode":null,"errorMessage":"Failed to connect to Databento LSG: {e}","messagePattern":"Failed to connect to Databento LSG: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"crates/adapters/databento/src/live.rs","lineNumber":598,"sourceCode":"            base.user_agent_extension(NAUTILUS_USER_AGENT.into())\n                .key(api_key.expose_secret().to_owned())?\n                .dataset(dataset)\n                .build()\n                .await\n        })\n        .await?;\n\n        let mut client = match result {\n            Ok(client) => {\n                if attempt > 1 {\n                    log::info!(\"Reconnected successfully\");\n                } else {\n                    log::info!(\"Connected\");\n                }\n                client\n            }\n            Err(e) => {\n                anyhow::bail!(\"Failed to connect to Databento LSG: {e}\");\n            }\n        };\n\n        // Process any commands buffered during reconnection backoff\n        let mut start_buffered = false;\n\n        if !self.buffered_commands.is_empty() {\n            log::debug!(\n                \"Processing {} buffered commands\",\n                self.buffered_commands.len()\n            );\n\n            for cmd in self.buffered_commands.drain(..) {\n                match cmd {\n                    HandlerCommand::Subscribe(sub) => {\n                        if !self.replay && sub.start.is_some() {\n                            self.replay = true;\n                        }","sourceCodeStart":580,"sourceCodeEnd":616,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/databento/src/live.rs#L580-L616","documentation":"This error is thrown by the Databento live streaming adapter when the initial or reconnecting call to establish the LSG (Live Streaming Gateway) client connection fails. The underlying Databento client error (authentication, network, DNS, subscription limits) is wrapped via anyhow::bail. It aborts run_session before any data is received.","triggerScenarios":"run_session calls client connect; the handshake returns Err — bad API key, unreachable gateway host, network outage, or Databento rejecting the dataset/subscription.","commonSituations":"Expired or invalid DATABENTO_API_KEY, no internet / DNS failure, wrong dataset id, firewall blocking the LSG port, Databento service maintenance windows.","solutions":["Verify the Databento API key is valid and has access to the configured dataset","Check network connectivity and that the LSG host/port is reachable (no firewall/proxy block)","Retry after checking Databento status page for outages","Review the wrapped inner error {e} for the root cause (auth vs network)"],"exampleFix":"// before\nclient connect fails silently with generic key\napi_key: Option<String>\n// after\nlet api_key = std::env::var(\"DATABENTO_API_KEY\")\n    .expect(\"DATABENTO_API_KEY must be set\");","handlingStrategy":"retry","validationCode":"let api_key = std::env::var(\"DATABENTO_API_KEY\")?;\nassert!(!api_key.is_empty());","typeGuard":null,"tryCatchPattern":"match adapter.run().await {\n    Ok(_) => {},\n    Err(e) if e.to_string().contains(\"Failed to connect\") => {\n        tokio::time::sleep(BACKOFF).await; // then retry\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Validate the Databento API key at startup before going live","Confirm dataset and subscription entitlements in the Databento dashboard","Check network/firewall access to the LSG endpoint before deploying","Monitor Databento status for maintenance windows"],"tags":["network","databento","live-streaming","connection"],"backgroundTag":"connection-refused","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}