简体   繁体   English

“node index.js”(EADDRINUSE)时节点服务器错误

[英]node server error when “node index.js” (EADDRINUSE)

On Mint Maya 64, if I run "node index.js" (v0.10.21) in terminal, I get this error: 在Mint Maya 64上,如果我在终端中运行“node index.js”(v0.10.21),我会收到此错误:

events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: listen EADDRINUSE
    at errnoException (net.js:901:11)
    at Server._listen2 (net.js:1039:14)
    at listen (net.js:1061:10)
    at Server.listen (net.js:1127:5)
    at Object.<anonymous> (/home/USER/Desktop/server/index.js:73:24)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)

my apache2 server is stopped, and there is no other node server running. 我的apache2服务器已停止,并且没有其他节点服务器正在运行。

I tried "killall node" -> node: no process found 我试过“killall node” - > node:找不到进程

With "sudo netstat -tulpn" there is no sign of anything listening on port 80. 使用“sudo netstat -tulpn”,没有任何迹象表明端口80正在侦听。

Because it's the first node server experiment for me, I don't have a clue how to proceed. 因为它是我的第一个节点服务器实验,我不知道如何继续。

Check which port is used by Node in your index.js file, for a start. 检查index.js文件中Node使用哪个端口作为开始。 There is another application which uses this port. 还有另一个使用此端口的应用程序。 So you have two options: 所以你有两个选择:

  • kill this app 杀了这个程序
  • use another port for Node app 使用Node app的另一个端口

Clearly, the port is occupied in EADDRINUSE error. 显然,端口在EADDRINUSE错误中占用。 As already stated, you either have to use the other port or kill the application. 如前所述,您必须使用其他端口或终止应用程序。

Other thing you can do is to identify the process that is occupying that particular port and kill that(this really comes handy in some concepts) 您可以做的其他事情是确定占用该特定端口的进程并将其杀死(这在某些概念中非常方便)

You can use fuser utility here. 您可以在此处使用fuser实用程序。

About Fuser 关于Fuser

The fuser command is a very smart UNIX utility used to find which process is using a file, a directory or a socket. fuser命令是一个非常智能的UNIX实用程序,用于查找哪个进程正在使用文件,目录或套接字。 It also gives information about the user owning the process and the type of access. 它还提供有关拥有进程和访问类型的用户的信息。 The fuser tool displays the process id(PID) of every process using the specified files or file systems. 热熔器工具使用指定​​的文件或文件系统显示每个进程的进程ID(PID)。

Providing here one relevant link for fuser. 这里提供一个相关的热熔器链接。

https://www.digitalocean.com/community/tutorials/how-to-use-the-linux-fuser-command https://www.digitalocean.com/community/tutorials/how-to-use-the-linux-fuser-command

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM