Codex 提示:登录失败:failed to start login server: Port 127.0.0.1:1455 is already in use

Windows / WSL 提示 Port already in use 但查不到占用(WinNAT 导致)

最近在使用 CLI 登录 Codex 时遇到报错:

Port 127.0.0.1:1455 is already in use

第一反应是端口被占用,于是检查:

Windows:

netstat -ano | findstr 1455

WSL:

ss -lntp | grep 1455

结果都查不到任何进程监听该端口。有时只能看到:


真正原因

后来检查 Windows 的系统保留端口:

netsh int ipv4 show excludedportrange protocol=tcp

发现输出中有:

Start Port    End Port
1412          1511

而问题端口 1455 正好在这个范围内

这说明端口不是被进程占用,而是被 Windows 系统保留(excluded port range)
这种情况通常是 WSL2 / Hyper-V / Docker / WinNAT 等组件创建的端口排除范围。


解决方法

重启 WinNAT 即可:

net stop winnat
net start winnat

总结

如果遇到:

  • 程序提示 port already in use
  • netstat 查不到端口占用

可以检查:

netsh int ipv4 show excludedportrange protocol=tcp

很可能是 Windows 系统保留端口导致的,而不是进程占用


posted @ 2026-03-11 16:50  7shuo  阅读(1891)  评论(0)    收藏  举报