{"record":{"id":"1acd8c7c0c3c207e","repo":"SubtitleEdit/subtitleedit","slug":"llama-server-did-not-report-healthy-within-5-minut","errorCode":null,"errorMessage":"llama-server did not report healthy within 5 minutes. Last output: {lastOutput}","messagePattern":"llama-server did not report healthy within 5 minutes\\. Last output: (.+?)","errorType":"exception","errorClass":"TimeoutException","httpStatus":null,"severity":"critical","filePath":"src/libuilogic/LlamaCpp/LlamaCppServerManager.cs","lineNumber":631,"sourceCode":"                    _serverProcess = null;\n                    _serverPort = 0;\n                    _serverModelPath = null;\n                    throw new InvalidOperationException(\n                        $\"llama-server exited during startup (code {process.ExitCode}). Output: {tail}\");\n                }\n\n                if (await ProbeHealthAsync(port, TimeSpan.FromSeconds(2), cancellationToken))\n                {\n                    Configuration.Settings.Tools.LlamaCppApiUrl = ApiUrl;\n                    return;\n                }\n\n                await Task.Delay(TimeSpan.FromSeconds(1), cancellationToken);\n            }\n\n            var lastOutput = SnapshotServerLog();\n            StopServerInternal();\n            throw new TimeoutException(\n                $\"llama-server did not report healthy within 5 minutes. Last output: {lastOutput}\");\n        }\n        finally\n        {\n            ServerLock.Release();\n        }\n    }\n\n    public static void StopServer()\n    {\n        ServerLock.Wait();\n        try\n        {\n            StopServerInternal();\n        }\n        finally\n        {\n            ServerLock.Release();","sourceCodeStart":613,"sourceCodeEnd":649,"githubUrl":"https://github.com/SubtitleEdit/subtitleedit/blob/17a9f0748781032255db3526b7215d2fb891e3af/src/libuilogic/LlamaCpp/LlamaCppServerManager.cs#L613-L649","documentation":"TimeoutException thrown when the 5-minute startup deadline elapses without llama-server's /health probe succeeding AND the process never exited. So the server is still running but unresponsive. The message embeds the last captured server output via SnapshotServerLog and the manager then calls StopServerInternal() to clean up.","triggerScenarios":"Server boots, takes longer than 5 minutes to load the model, and has not answered ProbeHealthAsync on the chosen loopback port. Common on CPU-only hosts loading large models, slow disks, or when the server binds a different port/interface than the probe expects.","commonSituations":"Large 70B-class model on a slow CPU; cold disk cache; model being memory-mapped off network storage; AV scanning the .gguf during load; server printing 'loading model' for many minutes.","solutions":["Use a smaller quant or a faster model so load completes well inside 5 minutes on your hardware.","Keep the .gguf on local SSD so memory-map load is fast; avoid network/USB storage.","If 5 minutes is genuinely too short for your hardware, raise the deadline constant in StartServer (it is currently hardcoded).","Reproduce the launch manually and time how long 'model loaded' takes; if it never appears, the model is too large for available RAM and is thrashing.","Confirm ProbeHealthAsync targets the same loopback port FindFreeLoopbackPort returned — a port mismatch makes the probe miss a healthy server."],"exampleFix":"// before\nvar deadline = DateTime.UtcNow.AddMinutes(5);\n\n// after — derive from model size so big models get more headroom\nvar loadMinutes = EstimateLoadMinutes(modelPath) switch { > 0 => Math.Max(5, EstimateLoadMinutes(modelPath)), _ => 5 };\nvar deadline = DateTime.UtcNow.AddMinutes(loadMinutes);","handlingStrategy":"retry","validationCode":"var estimatedLoadMinutes = Math.Max(5, new FileInfo(modelPath).Length / (200L * 1024 * 1024)); // ~200MB/min crude floor\nvar deadline = DateTime.UtcNow.AddMinutes(estimatedLoadMinutes);","typeGuard":"null","tryCatchPattern":"try { await StartServerAsync(model, token); }\ncatch (TimeoutException ex) { SeLogger.Error(ex, \"Health probe timed out; consider a smaller model or local SSD.\"); throw; }","preventionTips":["Benchmark model load time on your hardware before relying on the 5-minute default.","Keep .gguf files on local SSD; network/USB storage dominates load time.","Verify the health-probe port equals the server bind port before treating slow-loads as timeouts."],"tags":["llama-cpp","timeout","startup","performance","health-probe"],"backgroundTag":null,"analyzedSha":"17a9f0748781032255db3526b7215d2fb891e3af","analyzedAt":"2026-08-13T18:11:43.374Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}