{"record":{"id":"fb328cf7e7caecb3","repo":"apache/cassandra","slug":"server-is-not-initialized-yet-cannot-run-nodetool","errorCode":null,"errorMessage":"Server is not initialized yet, cannot run nodetool.","messagePattern":"Server is not initialized yet, cannot run nodetool\\.","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/tools/NodeTool.java","lineNumber":234,"sourceCode":"                break;\n            case PICOCLI:\n                break;\n            default:\n                throw new IllegalStateException(\"Unknown CLI layout: \" + layout);\n        }\n    }\n\n    protected void badUse(Exception e)\n    {\n        output.out.println(\"nodetool: \" + e.getMessage());\n        output.out.println(\"See 'nodetool help' or 'nodetool help <command>'.\");\n    }\n\n    protected void err(Throwable e)\n    {\n        // CASSANDRA-11537: friendly error message when server is not ready\n        if (e instanceof InstanceNotFoundException)\n            throw new IllegalArgumentException(\"Server is not initialized yet, cannot run nodetool.\");\n\n        output.err.println(\"error: \" + e.getMessage());\n        output.err.println(\"-- StackTrace --\");\n        output.err.println(getStackTraceAsString(e));\n    }\n\n    /**\n     * Rewrites global {@code -pp/--print-port} options that have been moved\n     * to subcommands via @Mixin for backward compatibility. When a user types:\n     * <pre>\n     *   nodetool -pp status\n     *   nodetool --print-port status -r\n     * </pre>\n     * this method rewrites them to:\n     * <pre>\n     *   nodetool status -pp\n     *   nodetool status -r --print-port\n     * </pre>","sourceCodeStart":216,"sourceCodeEnd":252,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/tools/NodeTool.java#L216-L252","documentation":"NodeTool's err() is the generic failure reporter for nodetool commands. When the underlying failure is a JMX InstanceNotFoundException, it converts it into an IllegalArgumentException stating the server is not initialized, because the MBean (Cassandra's storage service) has not yet been registered in the platform MBean server, so nodetool cannot operate.","triggerScenarios":"Running any nodetool command against a node whose server side (MBeans) is not yet registered — i.e. Cassandra is still starting up, is shutting down, or the JMX connection resolved but the expected MBean is absent. err() is called from NodeTool's execute path after the command threw InstanceNotFoundException.","commonSituations":"Scripts that run nodetool immediately after restarting Cassandra before it finishes startup; node crashed mid-boot so JMX agent is up but MBeans are not registered; connecting to the wrong host/port where a different JMX app is running; Cassandra hanging during startup (e.g. bootstrap or schema disagreement) so MBeans never appear.","solutions":["Wait until Cassandra has fully started (check system.log for 'Startup complete' or poll `nodetool status` in a retry loop) before running nodetool","Verify you are connecting to the correct JMX host/port (default 7199) of an actual Cassandra node","Check Cassandra logs for startup failure/hang and fix the underlying startup problem","Add retries/backoff in automation so nodetool runs only once the node is up"],"exampleFix":"// before (script)\nnodetool status\n// after (retry until node is up)\nuntil nodetool status >/dev/null 2>&1; do echo \"waiting for node...\"; sleep 5; done\nnodetool status","handlingStrategy":"retry","validationCode":"#!/bin/bash\nuntil nodetool status >/dev/null 2>&1; do sleep 5; done\nnodetool \"$@\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Gate nodetool automation on Cassandra being fully started (log marker or successful nodetool probe)","Verify JMX host/port and credentials point at a live Cassandra node","Add retry-with-backoff around nodetool calls in deployment scripts"],"tags":["nodetool","jmx","startup","cassandra"],"backgroundTag":"service-unavailable","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}