Tag Archives: “Error: listen EADDRINUSE: address already in use 127.0.0.1:3000”

Error: listen EADDRINUSE: address already in use 127.0.0.1:3000

When I was working on a small Vue project today, I encountered this bug. When I entered the npm run dev command in the terminal, the command I configured in the package.json file: “dev”: “webpack-dev-server –open –port 3000 –hot” should have run After the webpack tool packages the code, it automatically opens the browser and listens to port 3000, but then it prompts an error on the terminal command line with the following error message.

PS C:\Users\LXD\Desktop\my-vue\vue-cms> npm run dev

[email protected] dev C:\Users\LXD\Desktop\my-vue\vue-cms

webpack-dev-server –open –port 3000 –hot

events.js:174
throw er; // Unhandled ‘error’ event
^

Error: listen EADDRINUSE: address already in use 127.0.0.1:3000
at Server.setupListenHandle [as listen2] (net.js:1253:19)
at listenInCluster (net.js:1318:12)
at GetAddrInfoReqWrap.doListen [as callback] (net.js:1451:7)
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:61:10)
Emitted ‘error’ event at:
at emitErrorNT (net.js:1297:8)
at process.tickCallback (internal/process/next_tick.js:63:19)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] dev: webpack-dev-server --open --port 3000 --hot
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\LXD\AppData\Roaming\npm-cache_logs\2019-05-23T14_10_58_853Z-debug.log
PS C:\Users\LXD\Desktop\my-vue\vue-cms>

According to the error prompt, Error: listen EADDRINUSE: address already in use 127.0.0.1:3000, meaning that port 3000 is already occupied. At this point, the solution I was looking for was

Open cmd

Run netstat -ano, find the line with the port number in the error message, and remember the last number

[Solved] Error: listen EADDRINUSE: address already in use 127.0.0.1:3000

When running Vue project, an error is reported, that is: listen eadlink: address already in use 127.0.0.1:3000, indicating that the 3000 port number is occupied

Solution:

1. Open CMD and execute netstat – Nao | findstr 3000 to query the program occupied by port 3000

You can see that the process with PID 12212 occupies port 3000. If you want to know its process name, you can use the following command: tasklist | findstr 12212

2. Execute taskkill/PID 12212 to terminate the program occupying the port number

12212 is the number above

attention!! There is a space after taskkill