{"record":{"id":"cd0852cae6fd47b6","repo":"apache/flink","slug":"invalid-port-configuration-port-must-be-between-0-cd0852","errorCode":null,"errorMessage":"Invalid port configuration. Port must be between 0and 65535, but range start was {}.","messagePattern":"Invalid port configuration\\. Port must be between 0and 65535, but range start was (.+?)\\.","errorType":"validation","errorClass":"IllegalConfigurationException","httpStatus":null,"severity":"error","filePath":"flink-core/src/main/java/org/apache/flink/util/NetUtils.java","lineNumber":436,"sourceCode":"            Iterator<Integer> rangeIterator;\n            String range = rawRange.trim();\n            int dashIdx = range.indexOf('-');\n            if (dashIdx == -1) {\n                // only one port in range:\n                final int port = Integer.parseInt(range);\n                if (!isValidHostPort(port)) {\n                    throw new IllegalConfigurationException(\n                            \"Invalid port configuration. Port must be between 0\"\n                                    + \"and 65535, but was \"\n                                    + port\n                                    + \".\");\n                }\n                rangeIterator = Collections.singleton(Integer.valueOf(range)).iterator();\n            } else {\n                // evaluate range\n                final int start = Integer.parseInt(range.substring(0, dashIdx));\n                if (!isValidHostPort(start)) {\n                    throw new IllegalConfigurationException(\n                            \"Invalid port configuration. Port must be between 0\"\n                                    + \"and 65535, but range start was \"\n                                    + start\n                                    + \".\");\n                }\n                final int end = Integer.parseInt(range.substring(dashIdx + 1));\n                if (!isValidHostPort(end)) {\n                    throw new IllegalConfigurationException(\n                            \"Invalid port configuration. Port must be between 0\"\n                                    + \"and 65535, but range end was \"\n                                    + end\n                                    + \".\");\n                }\n                if (start >= end) {\n                    throw new IllegalConfigurationException(\n                            \"Invalid port configuration.\"\n                                    + \" Port range end must be bigger than port range start.\"\n                                    + \" If you wish to use single port please provide the value directly, not as a range.\"","sourceCodeStart":418,"sourceCodeEnd":454,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-core/src/main/java/org/apache/flink/util/NetUtils.java#L418-L454","documentation":"When NetUtils.getPortRangeFromString parses an entry containing '-' as a range, it validates the start value; a start outside 0..65535 throws IllegalConfigurationException with 'range start was <n>'. Only the start bound is reported by this specific message. Same validation as the single-port case, applied to range[0].","triggerScenarios":"Range strings like '70000-70100' or '-100-100' style values whose first parsed integer fails isValidHostPort; e.g. config 'rest.bind-port: 99999-100000'.","commonSituations":"Mistyped range boundaries; ranges generated programmatically with off-by-orders-of-magnitude errors; configs migrated from systems allowing wider port numbers.","solutions":["Fix the start value in the range to a valid port (0..65535).","Re-check the whole range string since the end bound is validated right after — fix both at once.","Prefer explicit single ports unless a range is genuinely needed."],"exampleFix":"# before\nrest.bind-port: 70000-70100\n\n# after\nrest.bind-port: 7000-7100","handlingStrategy":"validation","validationCode":"static void validatePortRange(String def) {\n    for (String part : def.split(\",\")) {\n        String r = part.trim();\n        int dash = r.indexOf('-');\n        int start = Integer.parseInt(dash < 0 ? r : r.substring(0, dash));\n        Preconditions.checkArgument(start >= 0 && start <= 65535, \"bad range start: %s\", r);\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate both bounds of ranges where the config is authored.","Generate ranges from validated integers, not string concatenation."],"tags":["configuration","ports","validation","flink-core"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}