loading...

How to 'fix' nodemon giving EADDRINUSE when changing a file

mostalive profile image Willem van den Ende ・1 min read

TLDR: upgrade to nodemon 2.0.4 or higher.

Background

This was a '4 tabs problem' yesterday, posting this here to save you the trouble. I found quite a few solutions, including a recent one that were not as simple as just upgrading. What happened? I installed a starter kid for node.js, from someone else. It would serve my tiny experimental API just fine, but I'd get "Port already in use" after each server restart. Nodemon reloaded my server.js just fine, but it seemed the application port wasn't shut down soon enough.

Solution

Set "nodemon": "2.0.4" in package.json and you should be good to go.

Bonus - I learnt about 'fuser'

One of the incomplete solutions mentioned fuser, a handy linux command to work with open ports and files. fuser -k <YOURPORT>/tcp will kill the process using YOURPORT (adjust number to taste). It can do similar things for open files, as well as list them.

It does happen some times that I have development servers open, and can't use a port, but forgot which app is using that port, fuser is a quick way to find out which program it is, and if necessary kill it.

Posted on by:

mostalive profile

Willem van den Ende

@mostalive

Systemic thinker and doer, Software developer.

Discussion

markdown guide