{"record":{"id":"006568c35c9a7e1f","repo":"SonarSource/sonarqube","slug":"entries-in-property-s-must-not-mix-host-port-an","errorCode":null,"errorMessage":"Entries in property %s must not mix 'host:port' and 'host'. Provide hosts without port only or hosts with port only.","messagePattern":"Entries in property (.+?) must not mix 'host:port' and 'host'\\. Provide hosts without port only or hosts with port only\\.","errorType":"validation","errorClass":"MessageException","httpStatus":null,"severity":"error","filePath":"server/sonar-main/src/main/java/org/sonar/application/config/ClusterSettings.java","lineNumber":225,"sourceCode":"    if (!loopbackAddresses.isEmpty()) {\n      throw new MessageException(format(\"Property %s must not contain a loopback address: %s\", property.getKey(),\n        loopbackAddresses.stream().map(AddressAndPort::getHost).sorted().collect(Collectors.joining(\", \"))));\n    }\n  }\n\n  private void ensureLocalButNotLoopbackAddress(Property property, AddressAndPort addressAndPort) {\n    String host = addressAndPort.getHost();\n    if (!network.isLocal(host) || network.isLoopback(host)) {\n      throw new MessageException(format(\"Property %s must be a local non-loopback address: %s\", property.getKey(), addressAndPort.getHost()));\n    }\n  }\n\n  private static void ensureEitherPortsAreProvidedOrOnlyHosts(Property property, Set<AddressAndPort> addressAndPorts) {\n    Set<AddressAndPort> hostsWithoutPort = addressAndPorts.stream()\n      .filter(t -> !t.hasPort())\n      .collect(toSet());\n    if (!hostsWithoutPort.isEmpty() && hostsWithoutPort.size() != addressAndPorts.size()) {\n      throw new MessageException(format(\"Entries in property %s must not mix 'host:port' and 'host'. Provide hosts without port only or hosts with port only.\", property.getKey()));\n    }\n  }\n\n  private static class AddressAndPort {\n    private static final int NO_PORT = -1;\n\n    /**\n     * the host from setting, can be a hostname or an IP address\n     */\n    private final String host;\n    private final int port;\n\n    private AddressAndPort(String host, @Nullable Integer port) {\n      this.host = host;\n      this.port = port == null ? NO_PORT : port;\n    }\n\n    public String getHost() {","sourceCodeStart":207,"sourceCodeEnd":243,"githubUrl":"https://github.com/SonarSource/sonarqube/blob/184c821202192afc1c599fc912d0889b69fffa53/server/sonar-main/src/main/java/org/sonar/application/config/ClusterSettings.java#L207-L243","documentation":"For Elasticsearch host lists in cluster mode, all entries must be uniform: either every entry carries an explicit port ('host:port') or none do. ensureEitherPortsAreProvidedOrOnlyHosts detects a mixed list — some entries with ports, some without — and throws, since mixing would make the effective port selection ambiguous.","triggerScenarios":"checkClusterEsHosts parses sonar.cluster.es.hosts (or sonar.cluster.search.hosts with ports) into AddressAndPort entries; it throws when at least one entry lacks a port (hasPort()==false) while other entries in the same property do have one.","commonSituations":"Editing sonar.cluster.es.hosts to add a new node and forgetting to append its port; mixing DNS service names (which include ports) with bare hostnames; hand-written lists copied from different doc versions.","solutions":["Make all entries in the property consistent: either append the port to every host (host:port) or remove ports from all.","When relying on the default port, ensure every entry is a bare host so the default is applied uniformly.","Re-check the list after automation/template updates — partial regeneration often causes the mix."],"exampleFix":"// before (conf/sonar.properties)\nsonar.cluster.es.hosts=es1.internal:9001,es2.internal\n\n// after\nsonar.cluster.es.hosts=es1.internal:9001,es2.internal:9001","handlingStrategy":"validation","validationCode":"// shell: all es.hosts entries must uniformly have (or lack) a port\nhosts=$(grep -E '^sonar\\.cluster\\.es\\.hosts=' conf/sonar.properties | cut -d= -f2 | tr ',' '\\n')\nwith=$(echo \"$hosts\" | grep -c ':'); total=$(echo \"$hosts\" | grep -c .)\n[ \"$with\" -gt 0 ] && [ \"$with\" -ne \"$total\" ] && echo \"Mixed host and host:port entries\" && exit 1\ntrue","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pick one convention (all with ports) for sonar.cluster.es.hosts and stick to it","Regenerate the whole list from a single template, never patch entries by hand","Validate the list after every node addition/removal"],"tags":["configuration","cluster","elasticsearch","format"],"backgroundTag":"invalid-argument-format","analyzedSha":"184c821202192afc1c599fc912d0889b69fffa53","analyzedAt":"2026-09-09T12:23:51.573Z","contentChangedAt":"2026-09-09T12:23:51.573Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}