惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

阮一峰的网络日志
阮一峰的网络日志
博客园 - 司徒正美
D
DataBreaches.Net
宝玉的分享
宝玉的分享
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
博客园 - 【当耐特】
人人都是产品经理
人人都是产品经理
博客园 - Franky
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
IT之家
IT之家
博客园 - 三生石上(FineUI控件)
J
Java Code Geeks
腾讯CDC
博客园_首页
The Cloudflare Blog
S
SegmentFault 最新的问题
C
Check Point Blog
美团技术团队
爱范儿
爱范儿
大猫的无限游戏
大猫的无限游戏
Hugging Face - Blog
Hugging Face - Blog
T
The Blog of Author Tim Ferriss
A
About on SuperTechFans
Blog — PlanetScale
Blog — PlanetScale

Cyberia

复活吧微软边缘 - Cyberia 从零开始的EAC抓轨教程 - Cyberia Apophenia, 新时代补全工具 - Cyberia 浅谈博客设计 - Cyberia 爱软TV之GitHub - Cyberia 排印演进 - Cyberia EAC相关工具集合 - Cyberia 《C(金钱掌控)》观后感 - Cyberia C#在Windows UI开发中的衰落 - Cyberia 存储退潮 字体padding计算器 开源已死 如何写出优雅完整的音频元数据 自动化EAC音频抓取 起夜级家庭网络正在变得越来越重要 优化Powershell的启动时间 无JavaScript其实没有很重要 你不需要一个电纸书阅读器 文件分享的难题 为什么我不敢看都市 某科学的 SSH 算号指南 时代的辉夜姬 为什么 Pixi 是神 关于神椿的过去,当下以及未来,我的一点看法 Tahoe 的图标令人难评 The EVE of PUSHING LIMITS 在 Word 中通过制表符实现居中对齐等操作 编码之殇:前 Unicode 时代的 WAV 处理 sHELL 即地狱 WR1800K AX NAND 路由器刷入 Immortalwrt
解决部分应用在 Windows 平台下端口被随机占用的问题
Nullpinter · 2024-09-03 · via Cyberia

English Version: Solving the issue of ports being randomly occupied by some applications on the Windows platform

太长不看#

  1. 进入管理员终端,PowerShell 或者 CMD 都可以。
  2. 键入 netsh int ipv4 show dynamicport tcp 查看起始端口号是否为 1024,如果是,恭喜你遇到了和我一样的问题,不是则自求多福。
  3. 键入 netsh int ipv4 set dynamic tcp start=49152 num=16384netsh int ipv6 set dynamic tcp start=49152 num=16384 重设起始端口号。
  4. 重启电脑

原因#

Windows 可能在某次更新中会意外的重设动态端口范围至 1024,这其实和 Hyper-V 无关,但是!Hyper-V会随机占用在这个范围内的几千个端口作为保留服务,你还不能通过 netstat -ano 发现这一点。正常的动态端口范围应是 49152-6553512

显然,很多 APP 都会使用地位端口,比如 VBAN 默认使用的 6980,如果这个端口极为幸运的被 Hyper-V 所使用,其他应用就不能使用了。如果你的代理或者其他下载软件出现了这个问题,可以尝试使用 netsh int ipv4 show excludedportrange protocol=tcp 来检查是否被占用。

English#

TL;DR#

  1. Open an administrator terminal (PowerShell or CMD).
  2. Type netsh int ipv4 show dynamicport tcp to check if the starting port number is 1024. If it is, you’ve encountered the same issue as me. If not, you’re on your own.
  3. Type netsh int ipv4 set dynamic tcp start=49152 num=16384 and netsh int ipv6 set dynamic tcp start=49152 num=16384 to reset the starting port number.
  4. Restart your computer.

Reason#

Windows may accidentally reset the dynamic port range to 1024 during an update. This is actually unrelated to Hyper-V, but Hyper-V will randomly occupy several thousand ports within this range as reserved services, and you can’t even detect this using netstat -ano. The normal dynamic port range should be 49152-6553512.

Obviously, many apps use lower ports, such as VBAN which defaults to 6980. If this port is unluckily used by Hyper-V, other applications won’t be able to use it. If your proxy or other download software encounters this problem, you can try using netsh int ipv4 show excludedportrange protocol=tcp to check if it’s being occupied.

  1. https://learn.microsoft.com/en-us/troubleshoot/windows-server/networking/default-dynamic-port-range-tcpip-chang ↩ ↩2

  2. https://www.techtarget.com/searchnetworking/definition/dynamic-port-numbers ↩ ↩2