{"record":{"id":"0a6c050891a0d9b7","repo":"XX-net/XX-Net","slug":"can-t-found-acceptable-ports","errorCode":null,"errorMessage":"Can't found acceptable ports","messagePattern":"Can't found acceptable ports","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"code/default/launcher/win_compat_suggest.py","lineNumber":124,"sourceCode":"        return False\n\n    def search_port_range(self):\n        port_number = 16384\n        for port_start in range(10000, 45000, 5000):\n            port_end = port_start + port_number\n            acceptable = True\n            for port in self.service_ports:\n                if port_start <= port <= port_end:\n                    acceptable = False\n                    break\n\n            if acceptable:\n                return [port_start, port_number]\n\n    def change_reserved_port_range(self):\n        ports = self.search_port_range()\n        if not ports:\n            xlog.warn(\"Can't found acceptable ports\")\n            return\n\n        exec = b\"netsh\"\n        args = b\"int ipv4 set dynamic tcp start=%d num=%d\" % (ports[0], ports[1])\n        import win32elevate\n        win32elevate.elevateAdminRun(args, exec)\n\n    @staticmethod\n    def notify(title=\"Title\", msg=\"msg\"):\n        import ctypes\n        res = ctypes.windll.user32.MessageBoxW(None, msg, title, 1)\n        # Yes:1 No:2\n        return res\n\n\ndef get_process_list():\n    process_list = []\n    if os.name != \"nt\":","sourceCodeStart":106,"sourceCodeEnd":142,"githubUrl":"https://github.com/XX-net/XX-Net/blob/cfa5bc17b67676e467f37ec50766127e0ab5f0aa/code/default/launcher/win_compat_suggest.py#L106-L142","documentation":"change_reserved_port_range() found no acceptable alternative TCP dynamic port range via search_port_range(), so it refuses to run the elevated 'netsh int ipv4 set dynamic tcp start=... num=...' command and returns None. It is a warning: nothing is modified and the caller (check_and_resolve) must handle the None result.","triggerScenarios":"Calling check_and_resolve() (or change_reserved_port_range directly) when every candidate port range either overlaps a service port or falls inside Windows excluded port ranges, so search_port_range() returns an empty list.","commonSituations":"Hyper-V/WSL/Docker reserving most of the dynamic port range; a machine with many excluded ranges leaving no window for the ~10k-port dynamic range; overly strict search criteria in search_port_range; service ports sitting inside every candidate window.","solutions":["Run 'netsh int ipv4 show excludedportrange protocol=tcp' and inspect how much of the range is blocked; reboot can clear ephemeral Hyper-V reservations.","Freeze fewer ports or shrink the number of ports search_port_range demands so a window can be found.","Manually reserve a safe range with an admin shell: netsh int ipv4 set dynamic tcp start=49152 num=16384, then re-run check_and_resolve.","Disable Hyper-V/WSL if its reservations are consuming the entire dynamic range."],"exampleFix":"// before\ndef change_reserved_port_range(self):\n    ports = self.search_port_range()\n    if not ports:\n        xlog.warn(\"Can't found acceptable ports\")\n        return\n\n// after\ndef change_reserved_port_range(self):\n    ports = self.search_port_range()\n    if not ports:\n        xlog.warn(\"Can't found acceptable ports; try shrinking port_number or freeing excluded ranges\")\n        return None\n    return ports","handlingStrategy":"fallback","validationCode":"ranges = subprocess.check_output(\n    'netsh int ipv4 show excludedportrange protocol=tcp', shell=True)\nexcluded = sum(int(l.split()[1]) - int(l.split()[0])\n                for l in ranges.decode(errors='ignore').splitlines()\n                if len(l.split()) == 2 and l.split()[0].isdigit())\nif excluded > 14000:  # nearly whole dynamic range blocked\n    raise RuntimeError('Port space exhausted; reboot or disable Hyper-V reservations')","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Check excludedportrange output before attempting to relocate the dynamic range.","Keep the requested port_number small so a free window is easier to find.","Reboot to clear transient Hyper-V/WinNAT reservations before re-running."],"tags":["windows","netsh","port-reservation","ports","launcher"],"backgroundTag":"no-available-port-range","analyzedSha":"cfa5bc17b67676e467f37ec50766127e0ab5f0aa","analyzedAt":"2026-08-27T19:28:28.225Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}