{"record":{"id":"820ff9e53c9562f6","repo":"apache/cassandra","slug":"failed-to-connect-to-jmx","errorCode":null,"errorMessage":"Failed to connect to JMX","messagePattern":"Failed to connect to JMX","errorType":"console","errorClass":"InitializationException","httpStatus":null,"severity":"critical","filePath":"src/java/org/apache/cassandra/tools/nodetool/JmxConnect.java","lineNumber":134,"sourceCode":"        {\n            if (isNotEmpty(username))\n            {\n                if (isNotEmpty(passwordFilePath))\n                    password = readUserPasswordFromFile(username, passwordFilePath);\n\n                if (isEmpty(password))\n                    password = promptAndReadPassword();\n            }\n\n            probe(username.isEmpty() ? nodeProbeFactory.create(host, parseInt(port))\n                                     : nodeProbeFactory.create(host, parseInt(port), username, password));\n        }\n        catch (IOException | SecurityException e)\n        {\n            Throwable rootCause = Throwables.getRootCause(e);\n            output.printError(\"nodetool: Failed to connect to '%s:%s' - %s: '%s'.%n\", host, port,\n                         rootCause.getClass().getSimpleName(), rootCause.getMessage());\n            throw new InitializationException(\"Failed to connect to JMX\", e);\n        }\n    }\n\n    @Override\n    public void close() throws Exception\n    {\n        if (probe() == null)\n            return;\n        ((AutoCloseable) probe()).close();\n    }\n\n    private static String readUserPasswordFromFile(String username, String passwordFilePath)\n    {\n        String password = EMPTY;\n\n        File passwordFile = new File(passwordFilePath);\n        try (Scanner scanner = new Scanner(passwordFile.toJavaIOFile()).useDelimiter(\"\\\\s+\"))\n        {","sourceCodeStart":116,"sourceCodeEnd":152,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/tools/nodetool/JmxConnect.java#L116-L152","documentation":"When opening the JMX connection fails with IOException or SecurityException, the invoker prints the root cause (e.g. connection refused, auth failure) and wraps it in InitializationException 'Failed to connect to JMX'. It signals the target node's JMX endpoint is unreachable or denied.","triggerScenarios":"Node down; wrong host/port (JMX_PORT, cassandra-env JMX_REMOTE_PORT); firewall blocking; JMX authentication (cassandra-env LOCAL_JMX=yes vs remote) rejecting the credentials; SSL mismatch.","commonSituations":"Nodetool run off-host without remote JMX enabled; password file keystore misconfiguration; TLS cert hostname mismatch; java security policy blocks access.","solutions":["Verify the node is up and JMX is listening: netstat/ss on the JMX port (default 7199)","Set correct host/port on the nodetool -h/-p flags and check cassandra-env.sh JMX settings","If authentication is enabled, supply credentials or fix conf/cassandra-env.sh LOCAL_JMX/remote JMX setup","Check TLS/SSL settings match between client and server"],"exampleFix":"// before\nnodetool -h 10.0.0.99 -p 7199 jmx status\n// after\nnodetool -h 127.0.0.1 -p 7199 jmx status   # or start JMX on the node","handlingStrategy":"retry","validationCode":"// check reachability before invoking\nnew Socket().connect(new InetSocketAddress(host, jmxPort), 3000); // throws if unreachable","typeGuard":null,"tryCatchPattern":"try { invoker.execute(parseResult); } catch (InitializationException e) { if (e.getMessage().contains(\"Failed to connect\")) { /* check host/port/creds, retry */ } }","preventionTips":["Confirm JMX remote access is enabled in cassandra-env.sh before off-host use","Monitor the JMX port (7199) health","Keep JMX auth credentials in sync between nodetool and server config"],"tags":["jmx","network","connection"],"backgroundTag":"connection-refused","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"}