{"record":{"id":"d6d4c70afc011bdc","repo":"karatelabs/karate","slug":"process-died-while-waiting-for-http","errorCode":null,"errorMessage":"process died while waiting for HTTP {}","messagePattern":"process died while waiting for HTTP (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"karate-core/src/main/java/io/karatelabs/process/PortUtils.java","lineNumber":87,"sourceCode":"            } catch (Exception e) {\n                logger.trace(\"port {}:{} not yet available (attempt {})\", host, port, i + 1);\n                sleep(intervalMs);\n            }\n        }\n        logger.warn(\"port {}:{} not available after {} attempts\", host, port, attempts);\n        return false;\n    }\n\n    /**\n     * Wait for an HTTP endpoint to return 200.\n     */\n    public static boolean waitForHttp(String url, int attempts, int intervalMs, BooleanSupplier stillAlive) {\n        HttpClient client = HttpClient.newBuilder()\n                .connectTimeout(Duration.ofSeconds(5))\n                .build();\n        for (int i = 0; i < attempts; i++) {\n            if (stillAlive != null && !stillAlive.getAsBoolean()) {\n                logger.warn(\"process died while waiting for HTTP {}\", url);\n                return false;\n            }\n            try {\n                HttpRequest request = HttpRequest.newBuilder()\n                        .uri(URI.create(url))\n                        .timeout(Duration.ofSeconds(5))\n                        .GET()\n                        .build();\n                HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());\n                if (response.statusCode() >= 200 && response.statusCode() < 300) {\n                    logger.debug(\"HTTP {} is available after {} attempts\", url, i + 1);\n                    return true;\n                }\n                logger.trace(\"HTTP {} returned {} (attempt {})\", url, response.statusCode(), i + 1);\n            } catch (Exception e) {\n                logger.trace(\"HTTP {} not available (attempt {}): {}\", url, i + 1, e.getMessage());\n            }\n            sleep(intervalMs);","sourceCodeStart":69,"sourceCodeEnd":105,"githubUrl":"https://github.com/karatelabs/karate/blob/a22eb90246d958d15a47bf436693d0121ad2812d/karate-core/src/main/java/io/karatelabs/process/PortUtils.java#L69-L105","documentation":"`PortUtils.waitForHttp` polls an HTTP URL expecting a response, but the `stillAlive` supplier reported the watched process died during the wait. It logs this warning and returns false rather than waiting for an endpoint that can never come up.","triggerScenarios":"Waiting for a child process's HTTP health endpoint via `waitForHttp(url, attempts, intervalMs, process::isAlive)`; the process crashes or exits before serving any HTTP response.","commonSituations":"Server failing on startup (bad config, missing port); unhandled exception in the app's bootstrap; container OOM-killed during startup; wrong URL/port in the wait call pointing nowhere while the process dies for an unrelated reason.","solutions":["Read the process output/logs to find the actual exit cause","Verify the URL and port match what the process actually serves","Ensure the process has sufficient memory and valid startup configuration","Fix the underlying startup failure and retry the wait"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"if (!PortUtils.waitForHttp(url, 60, 500, proc::isAlive)) {\n    // process died before serving: log proc output and exit code\n    throw new RuntimeException(\"process exited before HTTP endpoint \" + url + \" was ready\");\n}","preventionTips":["Pass a stillAlive supplier tied to the actual server process","Verify the health URL responds 200 via curl before automating","Ensure the process has enough memory/config to survive startup"],"tags":["process","http","health-check","lifecycle"],"backgroundTag":"process-exited-unexpectedly","analyzedSha":"a22eb90246d958d15a47bf436693d0121ad2812d","analyzedAt":"2026-09-12T09:01:00.220Z","contentChangedAt":"2026-09-12T09:01:00.220Z","schemaVersion":2},"datasetVersion":"2026-09-16T19:17:19.609Z"}