首页 > 解决方案 > 地址已在使用 :::8080 但端口未被任何进程使用

问题描述

我运行了这段代码:



var http = require('http');

http.createServer(function (req, res) {
    res.writeHead(200, {'Content-Type': 'text/plain'});
    res.end('Hello World!');
}).listen(8080);

我收到以下错误:

Error: listen EADDRINUSE: address already in use :::8080
    at Server.setupListenHandle [as _listen2] (net.js:1290:14)
    at listenInCluster (net.js:1338:12)
    at Server.listen (net.js:1425:7)
    at Object.<anonymous> (/home/dell/foo.js:6:4)
    at Module._compile (internal/modules/cjs/loader.js:707:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:718:10)
    at Module.load (internal/modules/cjs/loader.js:605:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:544:12)
    at Function.Module._load (internal/modules/cjs/loader.js:536:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:760:12)
Emitted 'error' event at:
    at emitErrorNT (net.js:1317:8)
    at internalTickCallback (internal/process/next_tick.js:72:19)
    at process._tickCallback (internal/process/next_tick.js:47:5)
    at Function.Module.runMain (internal/modules/cjs/loader.js:763:11)
    at startup (internal/bootstrap/node.js:303:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:872:3)

因此,这是我调用的一些代码,以找出在终端端口上运行的进程:


❯  fuser  8080/tcp

~

但事实证明,该端口上没有运行任何进程。

我该如何解决?

(我是 node.js 的新手。我将不胜感激任何正确方向的帮助。)

标签: node.js

解决方案


推荐阅读