📦端口已被占用
Error: listen EADDRINUSE: address already in use :::3000
这个编号(端口)已经被别的程序占用了,所以服务器启动不了。大多数情况是之前开着的开发服务器还在运行。
🤔 为什么会出现?
- 另一个终端窗口里已经开着开发服务器
- 服务器没有正常关闭,还在后台运行
🔧 试试这样做
- 找到另一个终端窗口,按 Ctrl + C 关掉服务器
- 也可以换一个端口启动(例如 npm run dev -- -p 3001)
- 还是不行的话,就重启电脑
🤖 这样问 AI
启动开发服务器时出现了下面的 EADDRINUSE 报错。我的电脑是 [Mac/Windows]。请一步步告诉我怎么找到占用这个端口的程序并把它关掉。 [在这里粘贴完整的报错]
把 [ ] 部分换成你的实际情况,报错前后的几行也尽量一起复制粘贴。
相关术语
同一分类的其他报错
- 找不到模块
Module not found: Can't resolve - 找不到命令
command not found - 包版本冲突(ERESOLVE)
npm ERR! ERESOLVE unable to resolve dependency tree - 类型不匹配(TypeScript)
Type 'X' is not assignable to type 'Y' - 没有权限,安装不了(EACCES)
EACCES: permission denied - Node 版本不匹配
The engine "node" is incompatible with this module - 内存不足(heap out of memory)
JavaScript heap out of memory - 不能使用 import 语句(模块设置)
SyntaxError: Cannot use import statement outside a module - 代码检查(ESLint)没通过,构建失败
Failed to compile — ESLint errors - 找不到文件或文件夹(ENOENT)
ENOENT: no such file or directory