I have been working with a node.js project for a few weeks and it has been working great.(我已经在一个node.js项目上工作了几周,并且运行良好。)
Usually I use 'npm start' to run my app and view it in a browser at on localhost, port 3000.(通常,我使用“ npm start”运行我的应用程序,并在浏览器上的本地主机端口3000上查看它。)
Today, I started to get the following error while using npm start:(今天,我在使用npm start时开始出现以下错误:)
Server started on port 3000
Port 3000 is already in use
I have checked the resource monitor and I have no other process running on port 3000. Why would I be getting this error message?(我已经检查了资源监视器,并且在端口3000上没有其他进程正在运行。为什么会出现此错误消息?)
In my app.js I have the following code to set the port...is this incorrect?(在我的app.js中,我有以下代码来设置端口...这不正确吗?) It worked fine before so I'm not sure what I am doing wrong.(之前效果很好,所以我不确定自己做错了什么。)
// Set Port
app.set('port', (process.env.PORT || 3000));
app.listen(app.get('port'), function() {
console.log('Server started on port '+app.get('port'));
});
Thanks for the help!(谢谢您的帮助!)
EDIT: I have tried running netstat and TCPView to check what process is using the port, but there is nothing using that port.(编辑:我已经尝试运行netstat和TCPView来检查正在使用该端口的进程,但是没有使用该端口的任何东西。) I also tried restarting my laptop but I still get the same error.(我也尝试过重新启动笔记本电脑,但仍然出现相同的错误。)
ask by user2573690 translate from so
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…