[英]MEAN App on server crashes
I try to run a MEAN App on an Nginx server, but it always crashes after:我尝试在 Nginx 服务器上运行一个 MEAN 应用程序,但它总是在以下情况下崩溃:
// port is 8080
app.listen(port, (data) => {
console.log('Listening on port ' + port + ' in ' + process.env.NODE_ENV + ' mode');
});
My firewall's status is我的防火墙状态是
Status: active
To Action From
-- ------ ----
OpenSSH ALLOW Anywhere
Nginx Full ALLOW Anywhere
8080 ALLOW Anywhere
OpenSSH (v6) ALLOW Anywhere (v6)
Nginx Full (v6) ALLOW Anywhere (v6)
8080 (v6) ALLOW Anywhere (v6)
Error错误
listen EADDRINUSE :::8080
I've used this tutorial to setup the server.我已经使用本教程来设置服务器。
Seems like 8080 is already in use, but how can I find out what it's used for and fix it?好像 8080 已经在使用了,但是我怎样才能找出它的用途并修复它呢?
Since you mentioned you followed the tutorial既然你提到你遵循了教程
https://www.digitalocean.com/community/tutorials/how-to-set-up-a-node-js-application-for-production-on-ubuntu-16-04 https://www.digitalocean.com/community/tutorials/how-to-set-up-a-node-js-application-for-production-on-ubuntu-16-04
This indicates you ran PM2 which is relaunching node even when you kill it.这表明您运行了 PM2,即使您杀死它,它也会重新启动节点。 So you need to stop PM2所以你需要停止PM2
sudo pkill PM2
Then you will be able to launch your node program normally然后你就可以正常启动你的节点程序了
To try getting what process is listening to a port enter:要尝试获取正在侦听端口的进程,请输入:
sudo netstat -tulpn | grep :8080
That should hopefully give you what is using that port.这应该有希望为您提供使用该端口的内容。
To then kill a process by PID, just use然后通过PID杀死进程,只需使用
sudo kill pid
fromhttps://www.cyberciti.biz/faq/what-process-has-open-linux-port/来自https://www.cyberciti.biz/faq/what-process-has-open-linux-port/
An alternative way is to just use sudo fuser -k 8080/tcp
to kill processes on port 8080 on TCP directly.另一种方法是使用sudo fuser -k 8080/tcp
直接终止 TCP 上端口 8080 上的进程。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.