{"record":{"id":"6a3ba5c9a941636e","repo":"LGUG2Z/komorebi","slug":"could-not-connect-to-komorebi-sock","errorCode":null,"errorMessage":"could not connect to komorebi.sock","messagePattern":"could not connect to komorebi\\.sock","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"komorebi/src/static_config.rs","lineNumber":1399,"sourceCode":"\n        #[allow(deprecated)]\n        match value.focus_follows_mouse {\n            None => WindowsApi::disable_focus_follows_mouse()?,\n            Some(FocusFollowsMouseImplementation::Windows) => {\n                WindowsApi::enable_focus_follows_mouse()?;\n            }\n            Some(FocusFollowsMouseImplementation::Komorebi) => {}\n        };\n\n        let bytes = SocketMessage::ReloadStaticConfiguration(path.clone()).as_bytes()?;\n\n        wm.hotwatch.watch(path, move |event| match event.kind {\n            // Editing in Notepad sends a NoticeWrite while editing in (Neo)Vim sends\n            // a NoticeRemove, presumably because of the use of swap files?\n            EventKind::Modify(_) | EventKind::Remove(_) => {\n                let socket = DATA_DIR.join(\"komorebi.sock\");\n                let mut stream =\n                    UnixStream::connect(socket).expect(\"could not connect to komorebi.sock\");\n                stream\n                    .write_all(&bytes)\n                    .expect(\"could not write to komorebi.sock\");\n            }\n            _ => {}\n        })?;\n\n        Ok(wm)\n    }\n\n    pub fn postload(path: &PathBuf, wm: &Arc<Mutex<WindowManager>>) -> eyre::Result<()> {\n        let mut value = Self::read(path)?;\n        let mut wm = wm.lock();\n\n        let configs_with_preference: Vec<_> =\n            DISPLAY_INDEX_PREFERENCES.read().keys().copied().collect();\n        let mut configs_used = Vec::new();\n","sourceCodeStart":1381,"sourceCodeEnd":1417,"githubUrl":"https://github.com/LGUG2Z/komorebi/blob/e0709f02bfae4e503bf4640f58ee75ecbbfdbb97/komorebi/src/static_config.rs#L1381-L1417","documentation":"Inside the static-config file watcher, on any config Modify/Remove event komorebi forwards the new bytes over a Unix domain socket at DATA_DIR/komorebi.sock, panicking if UnixStream::connect fails. This happens when no komorebi instance is listening on the socket (komorebi not running, stale socket file, or killed process).","triggerScenarios":"Saving or touching the watched static config file while the socket at DATA_DIR/komorebi.sock does not exist or refuses connection — komorebi not running, crashed, or a stale .sock left behind.","commonSituations":"Editing komorebi.json while komorebi is stopped; a stale komorebi.sock after an unclean shutdown; the `komorebic watch` helper outliving the main process.","solutions":["Start komorebi before (re)saving the config so a listener exists on the socket","Delete the stale komorebi.sock file in DATA_DIR and restart komorebi","Restart komorebic watch configuration after restarting komorebi","Replace the expect with graceful error logging so the watcher survives a dead socket"],"exampleFix":"// before\nUnixStream::connect(socket).expect(\"could not connect to komorebi.sock\");\n// after\nif let Err(e) = UnixStream::connect(socket) {\n    tracing::error!(\"could not connect to komorebi.sock: {e}\");\n    return;\n}","handlingStrategy":"validation","validationCode":"// confirm komorebi is listening before saving config / running komorebic watch\nlet sock = data_dir.join(\"komorebi.sock\");\nif !sock.exists() { eprintln!(\"komorebi not running: {sock:?} missing\"); }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Start komorebi before komorebic watch configuration","Delete stale komorebi.sock after unclean shutdowns","Restart the watcher whenever you restart komorebi"],"tags":["unix-socket","ipc","panic","config"],"backgroundTag":"connection-refused","analyzedSha":"e0709f02bfae4e503bf4640f58ee75ecbbfdbb97","analyzedAt":"2026-09-06T07:08:05.107Z","contentChangedAt":"2026-09-06T07:08:05.107Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}