{"record":{"id":"5c0ea02825a1efb1","repo":"apache/flink","slug":"invalid-port-configuration-port-must-be-between-0","errorCode":null,"errorMessage":"Invalid port configuration. Port must be between 0and 65535, but was {}.","messagePattern":"Invalid port configuration\\. Port must be between 0and 65535, but was (.+?)\\.","errorType":"validation","errorClass":"IllegalConfigurationException","httpStatus":null,"severity":"error","filePath":"flink-core/src/main/java/org/apache/flink/util/NetUtils.java","lineNumber":425,"sourceCode":"     * @param rangeDefinition String describing a single port, a range of ports or multiple ranges.\n     * @return Set of ports from the range definition\n     * @throws NumberFormatException If an invalid string is passed.\n     */\n    public static Iterator<Integer> getPortRangeFromString(String rangeDefinition)\n            throws NumberFormatException {\n        final String[] ranges = rangeDefinition.trim().split(\",\");\n\n        UnionIterator<Integer> iterators = new UnionIterator<>();\n\n        for (String rawRange : ranges) {\n            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)) {","sourceCodeStart":407,"sourceCodeEnd":443,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-core/src/main/java/org/apache/flink/util/NetUtils.java#L407-L443","documentation":"NetUtils.getPortRangeFromString validates every individual port in a port-range config string; a single (non-range) entry outside 0..65535 throws IllegalConfigurationException. The message (note the historical '0and' formatting typo) names the offending port. This is purely config validation, done before any socket is opened.","triggerScenarios":"A range string like '99999' or '0' style entries where isValidHostPort fails: port < 0 or > 65535, e.g. 'rest.bind-port: 70000' parsed as a single value; negative numbers like '-1' actually hit the range branch instead.","commonSituations":"Typos adding an extra digit (70000 instead of 7000); ports copied from another system with different limits; arithmetic building the port string overflowing.","solutions":["Correct the port value in the config to be within 0..65535 (typically 1024..65535 in practice).","Check the exact value echoed in the message and the config key in the stack trace.","Add a config lint step validating port ranges before deployment."],"exampleFix":"# before\nrest.bind-port: 91234\n\n# after\nrest.bind-port: 9123","handlingStrategy":"validation","validationCode":"static boolean isValidPort(int p) { return p >= 0 && p <= 65535; }\n// apply to every token of the port-range config before startup","typeGuard":null,"tryCatchPattern":"catch (IllegalConfigurationException e) { surface the offending config key to the deploy pipeline; treat as a deploy-time failure, not runtime. }","preventionTips":["Validate port configs in a pre-deploy lint step.","Prefer explicit single ports over ranges when possible."],"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"}