What is the problem?
npm run dev 报 EADDRINUSE address already in use,是端口被上一个没关的进程占着。给出 macOS/Linux 和 Windows 查端口、杀进程、换端口的真实命令,以及怎么避免再次发生。
Quick solution
Treat this as a Upwork troubleshooting issue. First confirm the environment, inputs, permissions, logs, and delivery boundary. Then use the linked deep guide for the full checklist before changing production code or promising a result.
Read the deep guideDetailed steps
- 关终端时进程没被一起结束(尤其后台 `&` 启动的);
- 用 `Ctrl+Z` 挂起而不是 `Ctrl+C` 结束;
- 同一个项目开了两个终端各起了一次 dev。
- `kill -9` / `taskkill /F` 是强制结束,杀错会中断别的服务(数据库、其他项目)。先确认 PID 再杀。
- 公司或服务器上的端口占用,可能是受管服务,别擅自杀,先确认归属和授权。
- [报错解释器](/tools/error-explainer)
Commands or code
# 查谁占了 3000 端口
lsof -i :3000
# 直接拿到 PID 并杀掉
lsof -ti:3000 | xargs kill -9Risk notes
Confirm the real project environment, account permissions, platform rules, and output quality before delivery. Do not ship AI-generated changes without human review, and do not claim indexing, income, deployment success, or ranking improvements without measured evidence.