{"record":{"id":"9764c0d6661d5a5c","repo":"testcontainers/testcontainers-java","slug":"could-not-perform-request-against-couchbase-http-endpoint","errorCode":null,"errorMessage":"Could not perform request against couchbase HTTP endpoint ","messagePattern":"Could not perform request against couchbase HTTP endpoint ","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"modules/couchbase/src/main/java/org/testcontainers/couchbase/CouchbaseContainer.java","lineNumber":840,"sourceCode":"        final boolean auth\n    ) {\n        try {\n            Request.Builder requestBuilder = new Request.Builder()\n                .url(\"http://\" + getHost() + \":\" + getMappedPort(port) + path);\n\n            if (auth) {\n                requestBuilder = requestBuilder.header(\"Authorization\", Credentials.basic(username, password));\n            }\n\n            if (body == null) {\n                requestBuilder = requestBuilder.get();\n            } else {\n                requestBuilder = requestBuilder.method(method, body);\n            }\n\n            return HTTP_CLIENT.newCall(requestBuilder.build()).execute();\n        } catch (Exception ex) {\n            throw new RuntimeException(\"Could not perform request against couchbase HTTP endpoint \", ex);\n        }\n    }\n\n    /**\n     * Helper method which times an individual phase and logs it for debugging and optimization purposes.\n     *\n     * @param name the name of the phase.\n     * @param toTime the runnable that should be timed.\n     */\n    private void timePhase(final String name, final Runnable toTime) {\n        long start = System.nanoTime();\n        toTime.run();\n        long end = System.nanoTime();\n\n        logger().debug(\"Phase {} took {}ms\", name, TimeUnit.NANOSECONDS.toMillis(end - start));\n    }\n\n    /**","sourceCodeStart":822,"sourceCodeEnd":858,"githubUrl":"https://github.com/testcontainers/testcontainers-java/blob/8e549514e3f01c57d70546fbb8599d138f3903e5/modules/couchbase/src/main/java/org/testcontainers/couchbase/CouchbaseContainer.java#L822-L858","documentation":"CouchbaseContainer's doHttpRequest wraps all failures from the OkHttp call against a Couchbase server HTTP endpoint (REST/Query/Analytics services) in a RuntimeException with this message. It means the HTTP request itself failed (connection error, bad URL, I/O problem), not that the server returned an error status.","triggerScenarios":"Any internal request made by response(), queryResponse(), or stateResponse() where OkHttp's execute() throws: container not reachable yet, wrong port mapping, hostname resolution failure, or interrupted I/O.","commonSituations":"Querying the container before Couchbase services are fully up during startup; network/firewall issues in CI; connecting with a stale container reference after the container stopped.","solutions":["Check the wrapped cause exception for the real network failure (connection refused, unknown host, timeout).","Ensure the container is running and fully initialized before triggering requests; rely on wait strategy completion.","Verify container port bindings and that no proxy env vars (HTTP_PROXY) interfere with localhost requests.","Retry after a short delay if hit during startup, since Couchbase services may not be listening yet."],"exampleFix":"// before\ncontainer.start();\ncontainer.query(\"SELECT 1\"); // may hit services not yet up\n// after\ncontainer.start();\nAwaitility.await().atMost(Duration.ofSeconds(30))\n    .untilAsserted(() -> container.query(\"SELECT 1\"));","handlingStrategy":"retry","validationCode":"if (!container.isRunning()) {\n    throw new IllegalStateException(\"Start the CouchbaseContainer before issuing HTTP requests\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    container.query(\"SELECT 1\");\n} catch (RuntimeException e) {\n    if (e.getMessage().startsWith(\"Could not perform request against couchbase HTTP endpoint\")) {\n        // inspect e.getCause(); back off and retry during startup\n    } else {\n        throw e;\n    }\n}","preventionTips":["Rely on Testcontainers wait strategies so requests only start after Couchbase is reachable.","Avoid proxy environment variables interfering with localhost calls in CI.","Always log the cause chain when wrapping HTTP failures."],"tags":["http","couchbase","network","request-failed"],"backgroundTag":"http-request-failed","analyzedSha":"8e549514e3f01c57d70546fbb8599d138f3903e5","analyzedAt":"2026-09-12T14:56:41.227Z","contentChangedAt":"2026-09-12T14:56:41.227Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}