Cannot start node inspector: "address already in use"
See original GitHub issueBug 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:
- Run
npx create-next-app - Add
"dev": "NODE_OPTIONS='--inspect' next"to scripts - Run
npm run dev - 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:
- Created 4 years ago
- Reactions:5
- Comments:5 (4 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Just updated the PR for that to solve it.
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-L91As 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 devcommand 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