linux - Node 服务器错误时 "node index.js"(EADDRINUSE)

标签 linux node.js ubuntu-12.04 linux-mint

在 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)

我的apache2服务器停止了,没有其他 Node 服务器在运行。

我试过“killall node” -> node: no process found

使用“sudo netstat -tulpn”,没有任何迹象表明在端口 80 上有任何监听。

因为这是我的第一个 Node 服务器实验,所以我不知道如何进行。

最佳答案

首先在您的 index.js 文件中检查 Node 使用的端口。 有另一个应用程序使用此端口。 所以你有两个选择:

  • 终止此应用
  • 为 Node 应用使用另一个端口

关于linux - Node 服务器错误时 "node index.js"(EADDRINUSE),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20865886/

相关文章:

用于安装 npm 模块的 Java 插件

javascript - C++ 级别的 nodeJS 模块加载

PHP后台作业到ubuntu xampp服务器,60-70分钟后被服务器中断

python - 'python' 命令损坏

bash - ssh脚本不会将控制权返回给父脚本

linux - 电力线不显示特殊符号

c++ - 为什么linux上一个动态链接的可执行文件在自己的内存空间里有libc的完整内存空间?

linux - ffmpeg每秒提取一帧视频?

c++ - 在 Linux 上为可执行文件创建导入库

node.js - 如何在 Node.js 中确定客户端操作系统