{"record":{"id":"3cc808cbc0e21579","repo":"apache/flink","slug":"invalid-port-configuration-port-must-be-between-0-3cc808","errorCode":null,"errorMessage":"Invalid port configuration. Port must be between 0and 65535, but range end was {}.","messagePattern":"Invalid port configuration\\. Port must be between 0and 65535, but range end was (.+?)\\.","errorType":"validation","errorClass":"IllegalConfigurationException","httpStatus":null,"severity":"error","filePath":"flink-core/src/main/java/org/apache/flink/util/NetUtils.java","lineNumber":444,"sourceCode":"                            \"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.\"\n                                    + \" Given range: \"\n                                    + range);\n                }\n                rangeIterator =\n                        new Iterator<Integer>() {\n                            int i = start;\n\n                            @Override","sourceCodeStart":426,"sourceCodeEnd":462,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-core/src/main/java/org/apache/flink/util/NetUtils.java#L426-L462","documentation":"NetUtils.getPortRangeFromString validates the end bound of a 'start-end' range entry; an end outside 0..65535 throws IllegalConfigurationException with 'range end was <n>'. It fires only after the start bound already passed validation. Pure config validation, thrown before any socket work.","triggerScenarios":"Range strings like '8081-99999' or '1000--1' whose second parsed integer fails isValidHostPort; building ranges via string concatenation that produces an invalid upper bound.","commonSituations":"Typos in the upper bound; copy-paste of ranges between configs; template variables for the upper bound resolving to invalid values.","solutions":["Fix the end value to a valid port within 0..65535 and greater than the start.","Check the echoed value and confirm the template/variable feeding it.","Validate generated range strings in tests before shipping config."],"exampleFix":"# before\nrest.bind-port: 8081-65536\n\n# after\nrest.bind-port: 8081-8181","handlingStrategy":"validation","validationCode":"static void validatePortRangeFull(String def) {\n    for (String part : def.split(\",\")) {\n        String[] bounds = part.trim().split(\"-\", 2);\n        int start = Integer.parseInt(bounds[0]);\n        int end = bounds.length > 1 ? Integer.parseInt(bounds[1]) : start;\n        Preconditions.checkArgument(end >= 0 && end <= 65535, \"bad range end: %s\", part);\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Check the upper bound whenever copying or templating ranges.","Reject configs where any token exceeds 65535 in CI."],"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"}