7

I don't know what happened but suddenly my Nodemon starting to show the error.

nikhil@nikhil-Lenovo-Z50-70:~/Desktop/dominos$ nodemon server.js
[nodemon] 1.12.1
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: *.*
[nodemon] starting `node server.js`
[nodemon] Internal watch failed: watch /home/nikhil/Desktop/dominos 
ENOSPC

Even though after that my program runs fine. But when I close this project1 and runs another project2 on the same port then this error occurs

Error: listen EADDRINUSE :::3000
at Object.exports._errnoException (util.js:1024:11)
at exports._exceptionWithHostPort (util.js:1047:20)
at Server.setupListenHandle [as _listen2] (net.js:1319:14)
at listenInCluster (net.js:1367:12)
at Server.listen (net.js:1467:7)
at Object.<anonymous> (/home/nikhil/Desktop/dominos/server.js:533:8)
at Module._compile (module.js:569:30)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:503:32)
at tryModuleLoad (module.js:466:12)
at Function.Module._load (module.js:458:3)
at Function.Module.runMain (module.js:605:10)
at startup (bootstrap_node.js:158:16)
at bootstrap_node.js:575:3

And then my old project1 would remain open and my new project2 cannot be started until I manually kill the process.

Any idea why this is happening??

Nikhil
  • 374
  • 1
  • 4
  • 21
  • the port 3000 is already used by another process – Lorenzo Marcon Oct 25 '17 at 16:59
  • Yes If I kill the process by using the Kill Command Then my projects run fine but this problem started to show from few days before that I was able to run the countless application with nodemon on the same port. – Nikhil Oct 25 '17 at 17:02

6 Answers6

11

Assuming you're on linux, the issue could be that you have too many open watchers. Run this command:

echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p

and try again.

Credit: this answer.

ronme
  • 1,154
  • 1
  • 11
  • 18
2

This issue is occurring because already another process or terminal use your same port

kill all node by using following command

killall node

start nodemon by using following comand

nodemon server.js
Eric Aya
  • 69,473
  • 35
  • 181
  • 253
Ganesh Apune
  • 197
  • 1
  • 6
2

In my case,

Error: [nodemon] Internal watch failed: EMFILE: too many open files, watch

Solution:

  1. I close the vs code,
  2. Reopen it, and solve the problem.
  • 1
    As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jan 20 '23 at 15:14
  • Worked for me too. it was that simple! Wasted one hour. – Maya Mar 29 '23 at 06:43
1

I had this same error. Node worked, but not nodemon. All I did was:

npm install -g nodemon

And it worked

Rob
  • 216
  • 3
  • 9
0

I've also faced this issue and I have tried all the solutions mentioned above but the solution works for me is just close the IDE and restart again the IDE it will help me.

0

This issue is occurs because nodemon is not installed properly please follow the instructions:

  • check your nodemon by using command nodemon -v.

version:
2.0.22

  • If you received nodemon version then it's working well otherwise use npm install nodemon -g command to install package.

  • use lsof -i -n -P | grep node command to check your node.js running PORTS such as:

output:
node 460517 adil 20u IPv6 13299837 0t0 TCP *:3003 (LISTEN)

  • if you received then kill unusable running PORTS by using kill -9 460517 command.

  • Run nodemon ./index.ts or npm start command.

Issue resolved.