Error: listen EADDRINUSE :::3000

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/you23hai45/article/details/86544259

1、错误描述

events.js:167
      throw er; // Unhandled 'error' event
      ^

Error: listen EADDRINUSE :::3000
    at Server.setupListenHandle [as _listen2] (net.js:1286:14)
    at listenInCluster (net.js:1334:12)
    at Server.listen (net.js:1421:7)
    at Object.<anonymous> (F:\Hworkspace\ES6\app.js:5:4)
    at Module._compile (internal/modules/cjs/loader.js:688:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:699:10)
    at Module.load (internal/modules/cjs/loader.js:598:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
    at Function.Module._load (internal/modules/cjs/loader.js:529:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:741:12)
Emitted 'error' event at:
    at emitErrorNT (net.js:1313:8)
    at process._tickCallback (internal/process/next_tick.js:63:19)
    at Function.Module.runMain (internal/modules/cjs/loader.js:744:11)
    at startup (internal/bootstrap/node.js:285:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:739:3)

2、错误原因

      由于运行这个Node.js,3000端口已经在运行监听,再次运行就会出现报错(之前未关闭)

const  http = require('http')
http.createServer((req,res) => {
	res.writeHead(200, { 'Content-Type': 'text/plain' });
	res.end("huhu");
}).listen(3000);

3、解决办法

     先关闭之前的进程,然后再重新运行

猜你喜欢

转载自blog.csdn.net/you23hai45/article/details/86544259