{"record":{"id":"59b6403e736f9b75","repo":"apache/druid","slug":"plaintextport-and-tlsport-cannot-be-null-or-same-i","errorCode":null,"errorMessage":"plaintextPort and tlsPort cannot be null or same if both http and https connectors are enabled","messagePattern":"plaintextPort and tlsPort cannot be null or same if both http and https connectors are enabled","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"server/src/main/java/org/apache/druid/server/DruidNode.java","lineNumber":197,"sourceCode":"    Integer portFromHostConfig;\n    if (host != null) {\n      hostAndPort = HostAndPort.fromString(host);\n      host = hostAndPort.getHost();\n      portFromHostConfig = hostAndPort.hasPort() ? hostAndPort.getPort() : null;\n      if (plainTextPort != null && portFromHostConfig != null && !plainTextPort.equals(portFromHostConfig)) {\n        throw new IAE(\"Conflicting host:port [%s] and port [%d] settings\", host, plainTextPort);\n      }\n      if (portFromHostConfig != null) {\n        plainTextPort = portFromHostConfig;\n      }\n    } else {\n      host = getDefaultHost();\n    }\n\n    if (enablePlaintextPort && enableTlsPort && ((plainTextPort == null || tlsPort == null)\n                                                 || plainTextPort.equals(tlsPort))) {\n      // If both plainTExt and tls are enabled then do not allow plaintextPort to be null or\n      throw new IAE(\"plaintextPort and tlsPort cannot be null or same if both http and https connectors are enabled\");\n    }\n    if (enableTlsPort && (tlsPort == null || tlsPort < 0)) {\n      throw new IAE(\"A valid tlsPort needs to specified when druid.enableTlsPort is set\");\n    }\n\n    if (enablePlaintextPort) {\n      // to preserve backwards compatible behaviour\n      if (nullHost && plainTextPort == null) {\n        plainTextPort = -1;\n      } else {\n        if (plainTextPort == null) {\n          plainTextPort = SocketUtil.findOpenPort(8080);\n        }\n      }\n      this.plaintextPort = plainTextPort;\n    } else {\n      this.plaintextPort = -1;\n    }","sourceCodeStart":179,"sourceCodeEnd":215,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/server/src/main/java/org/apache/druid/server/DruidNode.java#L179-L215","documentation":"When both plaintext and TLS listeners are enabled, DruidNode requires both ports to be set and distinct. If either port is null or they are equal, init() throws IAE since the two Jetty connectors would collide or one would be missing.","triggerScenarios":"druid.enablePlaintextPort=true and druid.enableTlsPort=true with druid.tlsPort unset, druid.port unset, or both set to the same number.","commonSituations":"TLS enablement added without adding a tlsPort value; copy-pasting druid.port into druid.tlsPort; property files where the port key was renamed and the old one lost.","solutions":["Set distinct values for druid.port and druid.tlsPort (e.g. 8081 and 8281)","Ensure the druid.tlsPort key exists in every enabled node's runtime.properties","Keep TLS and plaintext port assignments separate in your config templates"],"exampleFix":"// before\n  druid.enablePlaintextPort=true\n  druid.enableTlsPort=true\n  druid.port=8081\n  druid.tlsPort=8081\n// after\n  druid.port=8081\n  druid.tlsPort=8281","handlingStrategy":"validation","validationCode":"if (enablePlaintextPort && enableTlsPort\n    && (plainPort == null || tlsPort == null || plainPort.equals(tlsPort))) {\n  throw new IllegalArgumentException(\"Set distinct non-null druid.port and druid.tlsPort\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  node = new DruidNode(service, host, true, plainPort, tlsPort, false, false);\n} catch (IllegalArgumentException e) {\n  log.fatal(\"Bad TLS/port config: %s\", e.getMessage());\n  throw e;\n}","preventionTips":["Assign plaintext and TLS ports from distinct variables/port ranges","Verify both port keys exist whenever both enable flags are true","Check for copy-paste duplication of druid.port into druid.tlsPort","Validate config templates before rollout"],"tags":["configuration","druid-node","tls","ports"],"backgroundTag":"invalid-config-value","analyzedSha":"9b90983fd291f26935af934383ce360473179e4d","analyzedAt":"2026-09-07T13:32:30.957Z","contentChangedAt":"2026-09-07T13:32:30.957Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}