Error: listen EADDRINUSE :::4000 solution

created at 10-20-2021 views: 20

I recently took over an old project of angular 1.6, and encountered many problems during the development process, both at the code level and at the management level;

First record the problems encountered when the code is running

[15:45:15] Starting 'startserver'...
start webserver......
events.js:165
throw er; // Unhandled 'error' event
^

Error: listen EADDRINUSE :::4000
at Server.setupListenHandle [as _listen2] (net.js:1346:14)
at listenInCluster (net.js:1387:12)
at Server.listen (net.js:1475:7)
at Object. (D:\TeaGarden\ShareTeams\TeaGarden\WEB_Code\Client101901\app.js:52:8)
at Module._compile (internal/modules/cjs/loader.js:654:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:665:10)
at Module.load (internal/modules/cjs/loader.js:566:32)
at tryModuleLoad (internal/modules/cjs/loader.js:506:12)
at Function.Module._load (internal/modules/cjs/loader.js:498:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:695:10)
Emitted 'error' event at:
at emitErrorNT (net.js:1366:8)
at process._tickCallback (internal/process/next_tick.js:178:19)
at Function.Module.runMain (internal/modules/cjs/loader.js:697:11)
at startup (internal/bootstrap/node.js:201:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:516:3)
[15:45:16] 'startserver' errored after 1.4 s
[15:45:16] Error in plugin "gulp-shell"
Message:
Command node --nolazy app.js failed with exit code 1

reason

Node.js port conflict: listen EADDRINUSE :::4000

Two solutions:

  1. Modify the port number
  2. Kill the process occupying port 4000

Find the process occupying the port:

netstat -ano |findstr 4000
created at:10-20-2021
edited at: 10-20-2021: