nodemon: Reproducible: Error: listen EADDRINUSE :::3000

  • nodemon -v: 1.17.3
  • node -v: v9.11.2
  • Operating system/terminal environment: macOS High Sierra Version 10.13.6 (17G65) (Darwin Kernel Version 17.7.0: Thu Jun 21 22:53:14 PDT 2018; root:xnu-4570.71.2~1/RELEASE_X86_64)
  • Command you ran: complicated; see below

Expected behaviour

  • Clean restart of app
  • Listening on port again after a short time

Actual behaviour

  • The following error
events.js:167
      throw er; // Unhandled 'error' event
      ^

Error: listen EADDRINUSE :::3000
    at Server.setupListenHandle [as _listen2] (net.js:1328:14)
    at listenInCluster (net.js:1376:12)
    at Server.listen (net.js:1463:7)
    at Function.listen (/opt/code/node_modules/express/lib/application.js:618:24)
    at Object.<anonymous> (/opt/code/server.js:82:5)
    at Module._compile (internal/modules/cjs/loader.js:702:30)
    at loader (/opt/code/node_modules/babel-register/lib/node.js:144:5)
    at Object.require.extensions.(anonymous function) [as .js] (/opt/code/node_modules/babel-register/lib/node.js:154:7)
    at Module.load (internal/modules/cjs/loader.js:612:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:551:12)
Emitted 'error' event at:
    at emitErrorNT (net.js:1355:8)
    at process._tickCallback (internal/process/next_tick.js:63:19)
    at Function.Module.runMain (internal/modules/cjs/loader.js:746:11)
    at Object.<anonymous> (/opt/code/node_modules/babel-cli/lib/_babel-node.js:154:22)
    at Module._compile (internal/modules/cjs/loader.js:702:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:713:10)
    at Module.load (internal/modules/cjs/loader.js:612:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:551:12)
    at Function.Module._load (internal/modules/cjs/loader.js:543:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:744:10)
[nodemon] app crashed - waiting for file changes before starting...

Steps to reproduce

  1. Download nodemon-test.zip
  2. decompress zip
  3. open shell in decompressed dir
  4. Run make start-test

If applicable, please append the --dump flag on your command and include the output here ensuring to remove any sensitive/personal details or tokens.

About this issue

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

Most upvoted comments

I’ve been working on this today. The problem is in the ps tree implementation I took from node-kill-tree - basically it doesn’t work across all docker images.

I’m refactoring the pstree.remy so that it will work.

It’s because ps and how processes are killed, work slightly differently in the alpine flavour of linux.

This was previously working fine on v1.17.2.

However after upgrading to v1.18.7, this issue started happening. Tried to downgrade again to v1.17.2, it was not enough - the bug was still present.

It seems that the pstree.remy dependency had remained upgraded (to v1.1.2) from v1.18.7 - due to the semver.

Using v1.17.2, and adding the following workaround in package.json (for those using yarn) seems to have fixed it:

 "resolutions": {
   "nodemon/pstree.remy": "1.1.0"
 }

Live fix in nodemon@1.18.8 (core change in pstree.remy…again).

@zefexdeveloper Some people in this thread have said they can reproduce this without Docker. Does that still make this a duplicate?

I also confirmed that using v1.18.6, with the yarn resolution hack from above, works fine.

@servel333 the solution works only with yarn I believe not with npm With npm, you can downgrade to the version 1.13.3

@servel333 just add the that snippet to your package.json