Listen EADDRINUSE error while debugging in sails

2019-02-14 13:12发布

问题:

I am trying to debug my code using node-inspector but I am getting this error in my Terminal window again and again

$ sudo sails debug
info: Running app in debug mode...
info: You probably want to install / run node-inspector to help with debugging!
info: https://github.com/node-inspector/node-inspector

info: ( to exit, type <CTRL>+<C> )

    Error: listen EADDRINUSE
        at exports._errnoException (util.js:746:11)
        at Agent.Server._listen2 (net.js:1156:14)
        at listen (net.js:1182:10)
        at Agent.Server.listen (net.js:1267:5)
        at Object.start (_debugger_agent.js:20:9)
        at startup (node.js:86:9)
        at node.js:814:3

To resolve

Error : listen EADDRINUSE

I have tried closing other Terminal window (in which my node-inspector was running). I have referred to the answers already here on StackOverflow but they didn't work I have even tried giving this command to kill processes :

$ killall -9 node 
No matching processes belonging to you were found

but still its not working. Somebody please help me out with this.

回答1:

I see that you are using sudo so this is not a permissions issue.

It definitely seems like the port is already in use. You should check to see which process is using the port, then kill that process.



回答2:

There is a known issue with using sails debug on Node v12.0. There's a patch which will be released with the next version of Sails (v0.12).

In the meantime you can either install the edge version of Sails from Github or apply the patch yourself by replacing your Sails' /lib/hooks/grunt/index.js file with the contents of https://raw.githubusercontent.com/balderdashy/sails/88ffc0ed9949f8c74ea390efb5610b0e378fa02c/lib/hooks/grunt/index.js.



回答3:

First, find your task that uses port 1337:

netstat -ano | findstr : 1337 (port number)

Then kill it:

tskill (process ID (PID))

It can solve your problem