{"record":{"id":"352eecafca9ce8ea","repo":"eclipse-vertx/vert.x","slug":"port-p-must-be-65535","errorCode":null,"errorMessage":"port p must be < 65535","messagePattern":"port p must be < 65535","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"vertx-core/src/main/java/io/vertx/core/net/impl/SocketAddressImpl.java","lineNumber":64,"sourceCode":"    this.path = null;\n    this.port= address.getPort();\n    this.host = address.getHostString();\n    if (address.isUnresolved()) {\n      this.hostName = address.getHostName();\n      this.ipAddress = null;\n    } else {\n      String host = address.getHostString();\n      if (NetUtil.isValidIpV4Address(host) || NetUtil.isValidIpV6Address(host)) {\n        host = null;\n      }\n      this.hostName = host;\n      this.ipAddress = address.getAddress();\n    }\n  }\n\n  public SocketAddressImpl(int port, String host) {\n    if (port > 65535) {\n      throw new IllegalArgumentException(\"port p must be < 65535\");\n    }\n    this.path = null;\n    this.port = port;\n    if (NetUtil.isValidIpV4Address(host)) {\n      InetAddress ip;\n      try {\n        ip = InetAddress.getByAddress(NetUtil.createByteArrayFromIpAddressString(host));\n      } catch (UnknownHostException e) {\n        throw new VertxException(e);\n      }\n      this.host = host;\n      this.hostName = null;\n      this.ipAddress = ip;\n    } else if (NetUtil.isValidIpV6Address(host)) {\n      Inet6Address ip = NetUtil.getByName(host);\n      this.host = host;\n      this.hostName = null;\n      this.ipAddress = ip;","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/eclipse-vertx/vert.x/blob/fb308bd8c3f12c79f4ae89bef67fadf6c80d036e/vertx-core/src/main/java/io/vertx/core/net/impl/SocketAddressImpl.java#L46-L82","documentation":"SocketAddressImpl's (int port, String host) constructor rejects port values above 65535 with IllegalArgumentException. TCP/UDP ports are 16-bit; anything larger cannot be a valid port. Note the check is strict '> 65535', so 0 and negative are currently accepted by this check.","triggerScenarios":"Calling SocketAddress.inetSocketAddress(port, host) with port > 65535, typically a config value or a parsed string that is not a real port (e.g. '808080'), or combining host:port where the port portion was mis-parsed.","commonSituations":"Config files with 'port': 99999, parsing 'host:port' strings with wrong delimiter, byte-shift arithmetic errors producing values like 655360.","solutions":["Validate 0 <= port <= 65535 before calling the API","Fix the config value to a valid port","Check parsing logic that extracts the port from a string (Integer.parseInt on the substring after ':')"],"exampleFix":"// before\nint port = Integer.parseInt(args[1]); // e.g. 808080\nSocketAddress addr = SocketAddress.inetSocketAddress(port, \"example.com\");\n// after\nint port = Integer.parseInt(args[1]);\nif (port < 0 || port > 65535) throw new IllegalArgumentException(\"invalid port: \" + port);\nSocketAddress addr = SocketAddress.inetSocketAddress(port, \"example.com\");","handlingStrategy":"validation","validationCode":"if (port < 0 || port > 65535) throw new IllegalArgumentException(\"invalid port: \" + port);","typeGuard":null,"tryCatchPattern":"try {\n  addr = SocketAddress.inetSocketAddress(port, host);\n} catch (IllegalArgumentException e) {\n  // reject config, surface a clear message\n}","preventionTips":["Validate ports at config-load time (0..65535)","When parsing host:port strings, split on the last ':'","Type config ports as integers, not strings"],"tags":["port","validation","network"],"backgroundTag":"value-out-of-range","analyzedSha":"fb308bd8c3f12c79f4ae89bef67fadf6c80d036e","analyzedAt":"2026-09-06T11:37:12.241Z","contentChangedAt":"2026-09-06T11:37:12.241Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}