{"record":{"id":"5e3ad0eb03e9fe9b","repo":"testcontainers/testcontainers-java","slug":"timed-out-waiting-for-cassandra-to-be-accessible-for-query","errorCode":null,"errorMessage":"Timed out waiting for Cassandra to be accessible for query execution","messagePattern":"Timed out waiting for Cassandra to be accessible for query execution","errorType":"exception","errorClass":"org.testcontainers.containers.ContainerLaunchException","httpStatus":null,"severity":"error","filePath":"modules/cassandra/src/main/java/org/testcontainers/cassandra/CassandraQueryWaitStrategy.java","lineNumber":50,"sourceCode":"                    getRateLimiter()\n                        .doWhenReady(() -> {\n                            try (DatabaseDelegate databaseDelegate = getDatabaseDelegate()) {\n                                log.info(\"Checking connection is ready...\");\n                                ((CassandraDatabaseDelegate) databaseDelegate).execute(\n                                        SELECT_VERSION_QUERY,\n                                        StringUtils.EMPTY,\n                                        1,\n                                        false,\n                                        false,\n                                        true\n                                    );\n                            }\n                        });\n                    return true;\n                }\n            );\n        } catch (TimeoutException e) {\n            throw new ContainerLaunchException(TIMEOUT_ERROR);\n        }\n    }\n\n    private DatabaseDelegate getDatabaseDelegate() {\n        return new CassandraDatabaseDelegate(waitStrategyTarget);\n    }\n}\n","sourceCodeStart":32,"sourceCodeEnd":58,"githubUrl":"https://github.com/testcontainers/testcontainers-java/blob/8e549514e3f01c57d70546fbb8599d138f3903e5/modules/cassandra/src/main/java/org/testcontainers/cassandra/CassandraQueryWaitStrategy.java#L32-L58","documentation":"CassandraQueryWaitStrategy waits until the Cassandra container accepts CQL queries before the container is considered ready. If no successful query executes within the wait strategy timeout (default ~60s), it wraps the TimeoutException in a ContainerLaunchException with TIMEOUT_ERROR. This is Testcontainers' way of signaling the node never became queryable.","triggerScenarios":"container.start() on a CassandraContainer whose configured wait strategy is CassandraQueryWaitStrategy and the node fails to accept a CQL query (e.g. via getDatabaseDelegate().execute(\"SELECT keyspace_name FROM system_schema.keyspaces\")) before the timeout elapses.","commonSituations":"Slow machine or CI runners where Cassandra takes >60s to bootstrap; wrong image tag or JVM options causing the node to crash-loop; host port/resource exhaustion; storage driver issues.","solutions":["Increase the wait strategy timeout: new CassandraQueryWaitStrategy().withStartupTimeout(Duration.ofMinutes(5)) and set via container.waitingFor(...)","Check container logs (container.getLogs()) for Cassandra startup/crash errors","Use a lighter/supported Cassandra image tag (e.g. cassandra:4.x) and adequate memory (Cassandra needs several GB)","Ensure the host has enough free memory/CPU; Cassandra JVM heap defaults can OOM in constrained environments"],"exampleFix":"// before\nCassandraContainer c = new CassandraContainer(\"cassandra:3.11\");\nc.start();\n// after\nCassandraContainer c = new CassandraContainer(\"cassandra:3.11\");\nc.waitingFor(new CassandraQueryWaitStrategy().withStartupTimeout(Duration.ofMinutes(5)));\nc.start();","handlingStrategy":"retry","validationCode":"// Ensure adequate resources; check Docker is healthy before starting\nDockerClientFactory.instance().client();","typeGuard":null,"tryCatchPattern":"try { container.start(); } catch (ContainerLaunchException e) { /* inspect container.getLogs(), retry once with longer timeout */ }","preventionTips":["Set an explicit generous startup timeout for Cassandra","Allocate >=4GB memory for Cassandra containers","Check container logs on any start failure","Use a supported, pinned Cassandra image tag"],"tags":["cassandra","testcontainers","timeout","container-startup"],"backgroundTag":"request-timeout","analyzedSha":"8e549514e3f01c57d70546fbb8599d138f3903e5","analyzedAt":"2026-09-12T14:56:41.227Z","contentChangedAt":"2026-09-12T14:56:41.227Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}