
问题
Vite 启动项目时报错:Error: listen EACCES: permission denied ::1:5173
分析
Vite 3.0 开始把默认端口从 3000 改成了 5173。
这个问题最大的可能就是5173端口被占用,导致启动失败。通过以下命令查询后,发现并没有端口占用。1
> netstat -ano|findstr 5173
使用 netsh int ipv4 show excludedportrange protocol=tcp 命令查询,发现 5173 确实是保留端口。
能是被 WSL 和 HyperV 占用。

解决
保留端口尽量不能关闭,直接修改 Vite 的运行端口
在 vite.config 中加入如下配置:
server:{ host: ‘127.0.0.1’, port: 3000 }
正常启动:
