{"record":{"id":"45170acc2180a8cc","repo":"nautechsystems/nautilus_trader","slug":"failed-to-determine-hostname","errorCode":null,"errorMessage":"Failed to determine hostname","messagePattern":"Failed to determine hostname","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"crates/system/src/kernel.rs","lineNumber":465,"sourceCode":"            if cmd.trader_id != trader_id {\n                log::warn!(\"Received {cmd} not for this trader {trader_id}, ignoring\");\n                return;\n            }\n\n            if shutdown_requested.get() {\n                log::debug!(\"Shutdown already requested, ignoring {cmd}\");\n                return;\n            }\n\n            log::info!(\"Received {cmd}, requesting shutdown\");\n            shutdown_requested.set(true);\n        });\n        let topic = MessagingSwitchboard::shutdown_system_topic();\n        msgbus::subscribe_any(topic.into(), handler, None);\n    }\n\n    fn determine_machine_id() -> anyhow::Result<String> {\n        sysinfo::System::host_name().ok_or_else(|| anyhow::anyhow!(\"Failed to determine hostname\"))\n    }\n\n    fn initialize_logging(\n        trader_id: TraderId,\n        instance_id: UUID4,\n        config: LoggerConfig,\n    ) -> anyhow::Result<LogGuard> {\n        #[cfg(feature = \"tracing-bridge\")]\n        let use_tracing = config.use_tracing;\n\n        let file_config = config.file_config.clone().unwrap_or_default();\n        let log_guard = match init_logging(trader_id, instance_id, config, file_config) {\n            Ok(guard) => guard,\n            Err(e) => {\n                // Only recover from SetLoggerError (logger already registered).\n                // This is common in tests where multiple kernels are created and\n                // the log crate's global logger persists after LogGuard teardown.\n                // Any other error (e.g. thread spawn failure) is propagated.","sourceCodeStart":447,"sourceCodeEnd":483,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/system/src/kernel.rs#L447-L483","documentation":"Kernel initialization calls `sysinfo::System::host_name()` to derive a machine ID for the node. If the OS cannot provide a hostname (unusual for normal systems but possible in minimal containers), the Option is None and the kernel aborts startup with this anyhow error.","triggerScenarios":"Calling `Kernel::new` (which runs `determine_machine_id`) on a host where `sysinfo::System::host_name()` returns None — e.g. a container without a set hostname, a chroot with missing /etc/hostname, or a stripped-down environment.","commonSituations":"Running nautilus_system inside minimal Docker/Kubernetes pods with unset `hostname`, scratch containers lacking /etc/hostname or /proc, or sandboxes with restricted /sys access.","solutions":["Set an explicit hostname for the container/host (e.g. `docker run --hostname nautilus ...` or `hostnamectl set-hostname`).","Ensure /etc/hostname and /proc/sys/kernel/hostname are present and readable in the environment.","Upgrade or fix sysinfo availability: verify the process can read /proc/sys/kernel/hostname (mount /proc in the container).","If embedding, call `Kernel::new` only after the environment is fully initialized."],"exampleFix":"// before (Dockerfile)\nFROM scratch\nCOPY nautilus_app /app\nCMD [\"/app\"]\n\n// after\nFROM scratch\nCOPY nautilus_app /app\n# give the container a resolvable hostname\nCMD [\"/app\"]\n# run with: docker run --hostname nautilus-trader-1 ...","handlingStrategy":"validation","validationCode":"import socket\nhostname = socket.gethostname()\nif not hostname:\n    raise RuntimeError(\"Host has no hostname; set one before starting the kernel\")","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always run containers with an explicit --hostname/hostname field in the pod spec.","Verify /etc/hostname and /proc are mounted in minimal images before launch.","Smoke-test kernel initialization in the target deployment image in CI."],"tags":["hostname","kernel","environment","container"],"backgroundTag":"missing-env-var","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"}