微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

发生未处理的异常:端口4200已在使用中使用'--port'指定其他端口

如何解决发生未处理的异常:端口4200已在使用中使用'--port'指定其他端口

I tried to access localhost:4200 on my browser for my project. And the compile error message showed up each time I opened localhost4200. It says port 4200 is already in use. I tried online method like Ctrl+C but it doesn't work and have the error message shows up again. Could you help me with this problem? Thanks! The first screenshot is what my browser web page looks like when I go to localhost 4200.

This is what showed me in the terminal window after I run npm start. I could not run ng serve for some reasons. But the npm start works fine for me before.

解决方法

您可以使用以下方法杀死端口:

kill $(lsof -ti:4200)

然后再次运行ng serve

尽管您有两个很可能没有连接的不同问题。您在浏览器中看到的错误是由于代码错误所致,我们需要更多信息来帮助您进行修复。

,

这是在我的档案中。如何杀死Windows机器上的所有节点进程? taskkill /F /IM node.exe

这是另一种方法。

killall node

,

如果您使用Windows,则可以使用netstat -ano | findstr 4200获取pid 那么您可以使用taskkill / f / t / im yourpid关闭4200端口,然后重新启动它。希望它可以为您提供帮助

,

您可以杀死4200上运行的任务,也可以只使用ng serve --port 4201

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。