Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript Express Basics (2015) Developing Express Apps Like a Boss Easily Debug Express (and other node apps)

Michael Davis
Michael Davis
17,071 Points

getting various Error: listen EADDRINUSE :::3000/5858

happy friday folks!

i have been beating my head against the wall trying to solve this while running nodemon and node-inspector.

i keep getting this error:

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

Error: listen EADDRINUSE :::3000 at Object.exports._errnoException (util.js:1012:11) at exports._exceptionWithHostPort (util.js:1035:20) at Server._listen2 (net.js:1252:14) at listen (net.js:1288:10) at Server.listen (net.js:1384:5) at EventEmitter.listen (/Users/michaeldavis/treehouse-express-basics/MyFirstExpressApp/node_modules/express/lib/application.js:617:24) at Object.<anonymous> (/Users/michaeldavis/treehouse-express-basics/MyFirstExpressApp/app.js:16:5) at Module._compile (module.js:541:32) at Object.Module._extensions..js (module.js:550:10) at Module.load (module.js:458:32)

or i get it with the :::5858 rather than the :::3000 listed above.

i have tried all kinds of work arounds.

now i can't even run the app via basic node without getting this error, not to mention nodemon.

help????

4 Answers

Seth Kroger
Seth Kroger
56,413 Points

EADDRINUSE means there is already another running process that is listening to the port your node app wants to use and has it reserved. It's most likely you've run the app previously but it hasn't terminated properly and is still holding on to the port.

It can be fixed by looking for still-running node processes and ending them with the ps and kill -9 PID (where PID is the process number from ps) commands on Linux/MacOS terminal or Task Manager on Windows.

Michael Davis
Michael Davis
17,071 Points

Thanks seth! I am using the terminal app on OS X El Capitan What command do you use to find that still running node processes?

Also, do you think the versions of node, nodemon, node-inspector impact this at all?

Seth Kroger
Seth Kroger
56,413 Points

ps ux should cover any node commands you've launched. ps aux will show you all the processes going on your system.

Michael Davis
Michael Davis
17,071 Points

ok awesome. sorry, what i hope is the last question, and thanks again for answering them... i get a table of various columns and rows of information when i run either of those commands. in the columns, which on gives the port number?

these are the titles of the various columns returned:

USER PID %CPU %MEM VSZ RSS TT STAT STARTED TIME COMMAND

Seth Kroger
Seth Kroger
56,413 Points

The column you want is the PID (Process ID) column. Look for the PID of any node command and kill them.

Michael Davis
Michael Davis
17,071 Points

well that definitely helped and got things on the right track when it comes to getting my node app up and running again.

unfortunately, now i am seeing this error:

Error: Cannot find module '/usr/local/lib/node_modules/node-inspector/node_modules/v8-debug/build/debug/v0.7.7/node-v48-darwin-x64/debug.node'

when i am trying to run nodemon and node-inspector...

  1. run node-inspector
  2. run nodemon in separate terminal window
  3. refresh node-inspector at http://127.0.0.1:8080/?port=5858 which produces the error above

any help out there?

thanks many times over in advance