nodemon: Starting inspector on 0.0.0.0:9229 failed: address already in use

  • nodemon -v: 1.18.8
  • node -v: 9.4.0
  • Operating system/terminal environment: ubuntu 18.04
  • Using Docker? What image: docker -> FROM node:slim
  • Command you ran: ./node_modules/.bin/nodemon --inspect=0.0.0.0 --legacy-watch ./src ./src/index.js

Expected behaviour

inspector restart on file change

Actual behaviour

Starting inspector on 0.0.0.0:9229 failed: address already in use

Steps to reproduce

using a dockerfile like :

FROM node:slim

# Create app directory
WORKDIR /usr/app

# Install app dependencies
COPY package.json /usr/app/
RUN npm install

# Bundle app source
COPY . /usr/app

CMD [ "npm", "run", "watch" ]

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 19 (4 by maintainers)

Most upvoted comments

Sorry for upping this, but I’m having the exact same issue 😐

[edit]: Seems to be working fine with --signal SIGINT but it prevents the process from getting killed in development.

It’s fine in my case because it’s running in docker, but that’s probably not something fine

As described in #1476 I’m still seeing this issue with 1.18.9.

The issue is intermittent with the following start command:

./node_modules/.bin/nodemon --inspect=0.0.0.0:9229 ./index.js

Just add --delay 300ms into the command solved my problem.

https://github.com/remy/nodemon#delaying-restarting

I fixed my problem by changing the npm dev script and the nodemon exec command, to move the time of setting NODE_OPTIONS later, from this:

package.json: "dev": "NODE_OPTIONS=--inspect=0.0.0.0:9229 nodemon -L src/index.ts"
nodemon.json: "exec": "ts-node -r dotenv/config"

to this:

package.json: "dev": "nodemon -L src/index.ts"
nodemon.json: "exec": "NODE_OPTIONS=--inspect=0.0.0.0:9229 ts-node -r dotenv/config"

What must have been happening was that node and/or nodemon was taking over listening on the port, but ts-node was also trying to do the same thing. By setting the environment variable later, that is avoided.

I get this issue all the time. Not sure when exactly it started happening, but it didn’t use to happen.

node v11.11.0 via alpine-v11

─┬ nodemon@1.18.10
  └── pstree.remy@1.1.6
"dev": "nodemon -L -d 2 --inspect=0.0.0.0:9229 -- --icu-data-dir=$NODE_ICU_DATA_PATH index.js"

Would be happy to retrieve any logs or additional info to help narrow this down.