简体   繁体   中英

error that wont go away despite numerous changes in node.js

Good evening,

I have the following error and I have no idea what it means, i have googled and changed a few little bit but its very persistent. Is anyone able to offer me some help with the matter?

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

Error: listen EADDRINUSE: address already in use :::5000
    at Server.setupListenHandle [as _listen2] (net.js:1318:16)
    at listenInCluster (net.js:1366:12)
    at Server.listen (net.js:1452:7)
    at Object.<anonymous> (/Users/danielwilstrop/Desktop/projects/live-chat-2/server.js:100:8)
    at Module._compile (internal/modules/cjs/loader.js:1063:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
    at internal/main/run_main_module.js:17:47
Emitted 'error' event on Server instance at:
    at emitErrorNT (net.js:1345:8)
    at processTicksAndRejections (internal/process/task_queues.js:80:21) {
  code: 'EADDRINUSE',
  errno: -48,
  syscall: 'listen',
  address: '::',
  port: 5000
}
[nodemon] app crashed - waiting for file changes before starting...

This error is usually caused by a typo on your terminal. Check if you typed the correct file name in your terminal and also check if the path to your file is correct.

Option 2: check if no other terminals are open in the background. kill all those other terminals, press Ctr+C then run your app again..

There is some other process already using port 5000 so, you are getting this error. To solve this there are two ways

  1. Change the server port from 5000 to something else which port is available eg. 5555 in this file /Users/danielwilstrop/Desktop/projects/live-chat-2/server.js at line number 100 (as shown in the error)

  2. Kill the process that is running on port 5000. Then run the server.js file.

    For Linux or mac sudo lsof -ti tcp:5000 | sudo xargs kill sudo lsof -ti tcp:5000 | sudo xargs kill

    For windows run cmd with administrator privilages netstat -ano|findstr "PID:5000" take the process id from the output and then taskkill /pid <PROCESS_PID_USING_PORT_5000> /f

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM