question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot start node inspector: "address already in use"

See original GitHub issue

Bug report

After upgrading from Next 9.2.2 -> 9.3.0 the node inspector fails to start (crashing the Next process) with the error “Starting inspector on 0.0.0.0:9229 failed: address already in use”.

None of the suggestions offered in https://github.com/zeit/next.js/issues/10610 or https://github.com/zeit/next.js/issues/9027 have helped. Have also tested with Next 9.3.1-canary.3 and noted the same issue occurs.

To Reproduce

Steps to reproduce the behavior:

  1. Run npx create-next-app
  2. Add "dev": "NODE_OPTIONS='--inspect' next" to scripts
  3. Run npm run dev
  4. See error

Expected behavior

The node inspector starts normally without crashing the Next process.

System information

  • OS: macOS 10.15.3
  • Version of Next.js: 9.3.0+

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:5
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

12reactions
vvocommented, Mar 19, 2020

Just updated the PR for that to solve it.

7reactions
vvocommented, Mar 13, 2020

Update: I found the issue. When running next dev, the file next-dev-server.ts will launch a subprocess using jest-worker here: https://github.com/zeit/next.js/blob/6997b0236b68fd7c8f5395003c99a719974cc404/packages/next/server/next-dev-server.ts#L83-L91

As a result, another Node.js process is spawned with the same process.env.NODE_OPTIONS=‘–inspect’ and will also try to start a debugger on the same port than the one the main next dev command started just earlier.

This is a known issue from Node.js but there’s not much that they will do about it for good reasons, see https://github.com/nodejs/node/issues/9435#issue-186998002

But we can do something, I tried it and it works, just remove any --inspect flag from NODE_OPTIONS passed to the worker and done, see the PR: #11041

Read more comments on GitHub >

github_iconTop Results From Across the Web

Starting inspector failed: address already in use
This means the address is already in use by another Node.js app and you may have forgotten to exit it. Solution§.
Read more >
Starting inspector on 127.0.0.1:9229 failed: address already in ...
Steps to Reproduce: Hitting me (changed) [nodemon] files triggering change check: application/index.ts [nodemon] matched rule: /home/ ...
Read more >
VS Code: Starting inspector on 127.0.0.1:9229 failed
In the console I get "Starting inspector on 127.0.0.1:9229 failed: address already in use". I have not figured out what the problem is....
Read more >
Error: listen EADDRINUSE: address already in use 3000 | 8080
... Error: listen EADDRINUSE: address already in use in node js is shown events. js :292 throw er; ... Your browser can't play...
Read more >
15 Common Error Codes in Node.js and How to Fix Them
Therefore, we've compiled this list of 15 common Node.js errors ... Error: listen EADDRINUSE: address already in use :::3001 at Server.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found