{"record":{"id":"48951a4e7173f9b2","repo":"MyCATApache/Mycat-Server","slug":"node-host-duplicated-host","errorCode":null,"errorMessage":"node host duplicated :${host}","messagePattern":"node host duplicated :(.+?)","errorType":"exception","errorClass":"ConfigException","httpStatus":null,"severity":"error","filePath":"src/main/java/io/mycat/config/model/ClusterConfig.java","lineNumber":82,"sourceCode":"        Map<String, MycatNodeConfig> nodes = new HashMap<String, MycatNodeConfig>();\n        NodeList list = root.getElementsByTagName(\"node\");\n        Set<String> hostSet = new HashSet<String>();\n        for (int i = 0, n = list.getLength(); i < n; i++) {\n            Node node = list.item(i);\n            if (node instanceof Element) {\n                Element element = (Element) node;\n                String name = element.getAttribute(\"name\").trim();\n                if (nodes.containsKey(name)) {\n                    throw new ConfigException(\"node name duplicated :\" + name);\n                }\n\n                Map<String, Object> props = ConfigUtil.loadElements(element);\n                String host = (String) props.get(\"host\");\n                if (null == host || \"\".equals(host)) {\n                    throw new ConfigException(\"host empty in node: \" + name);\n                }\n                if (hostSet.contains(host)) {\n                    throw new ConfigException(\"node host duplicated :\" + host);\n                }\n\n                String wei = (String) props.get(\"weight\");\n                if (null == wei || \"\".equals(wei)) {\n                    throw new ConfigException(\"weight should not be null in host:\" + host);\n                }\n                int weight = Integer.parseInt(wei);\n                if (weight <= 0) {\n                    throw new ConfigException(\"weight should be > 0 in host:\" + host + \" weight:\" + weight);\n                }\n\n                MycatNodeConfig conf = new MycatNodeConfig(name, host, port, weight);\n                nodes.put(name, conf);\n                hostSet.add(host);\n            }\n        }\n        return nodes;\n    }","sourceCodeStart":64,"sourceCodeEnd":100,"githubUrl":"https://github.com/MyCATApache/Mycat-Server/blob/65f8d8beb752f935752f2a0eec0ab017facab9ef/src/main/java/io/mycat/config/model/ClusterConfig.java#L64-L100","documentation":"loadNode tracks hosts already seen in hostSet; if two different <node> elements declare the same host value, ConfigException 'node host duplicated : <host>' is thrown at ClusterConfig.java:82. Each cluster node must have a distinct host address so traffic can be routed unambiguously.","triggerScenarios":"Two <node> elements in cluster.xml both set property host to the same IP/hostname (e.g. 10.0.0.1); thrown when the second one is processed.","commonSituations":"Cloning a node block and forgetting to change the host, two nodes pointing at the same machine with only the port differing (not allowed here), or an HA setup modeled incorrectly.","solutions":["Search cluster.xml for the duplicated host value and give each node a unique host.","If both really are the same machine, use distinct hostnames (or per-interface IPs) and unique ports.","Remove redundant duplicate node definitions if they were accidental copy-paste.","Keep nodes and groups consistent after renaming hosts."],"exampleFix":"<!-- before -->\n<node name=\"nodeM1\" host=\"10.0.0.1\" port=\"3311\" />\n<node name=\"nodeS1\" host=\"10.0.0.1\" port=\"3312\" />\n<!-- after -->\n<node name=\"nodeM1\" host=\"10.0.0.1\" port=\"3311\" />\n<node name=\"nodeS1\" host=\"10.0.0.2\" port=\"3312\" />","handlingStrategy":"validation","validationCode":"// No two nodes may share the same host\njava.util.Set<String> hosts = new java.util.HashSet<>();\nvar nl = doc.getElementsByTagName(\"node\");\nfor (int i = 0; i < nl.getLength(); i++) {\n  var el = (Element) nl.item(i);\n  String host = hostOf(el); // read property name=\"host\"\n  if (!hosts.add(host)) throw new IllegalStateException(\"duplicate host: \" + host);\n}","typeGuard":null,"tryCatchPattern":"try { new ClusterConfig(); } catch (ConfigException e) { if (e.getMessage().startsWith(\"node host duplicated\")) { log.error(\"Assign a unique host per <node> in cluster.xml\"); } throw e; }","preventionTips":["Maintain an IP/hostname allocation sheet per cluster","Never clone node blocks without changing host","Use distinct hostnames per node even on shared machines","Add a duplicate-host check to deployment scripts"],"tags":["xml","config","duplicate-host","cluster","mycat"],"backgroundTag":"invalid-config-value","analyzedSha":"65f8d8beb752f935752f2a0eec0ab017facab9ef","analyzedAt":"2026-09-11T00:12:21.696Z","contentChangedAt":"2026-09-11T00:12:21.696Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}