Sunday, August 9, 2015

Problem with NodeJs - node --debug server.js:72 - throw er; // Unhandled 'error' event

When playing around with debugging NodeJs and entering the following:

$ node --debug server.js

I got this error:

        throw er; // Unhandled 'error' event
Error: listen EADDRINUSE
    at errnoException (net.js:905:11)
    at Server._listen2 (net.js:1043:14)

    at listen (net.js:1065:10)

This is caused by starting and stopping these debug processes, but leaving one running.

Run the following to identify the running process and then kill it.

Johns-MBP:server john$ ps aux | grep node

This will present something like this:
john      2799   0.0  0.3  3129308  52852   ??  S    11:38AM   0:01.30 /usr/local/Cellar/nvm/0.18.0/v0.10.33/bin/node --debug-brk=49961 --nolazy server.js
john      3023   0.0  0.0  2432772    660 s002  S+    2:37PM   0:00.00 grep node

This has told us the processId to kill. So run kill -9 [the process id]

Johns-MBP:server johnroberts$ kill -9 2799