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.

Still getting 'address already in use' using --inspect on typescript projects

See original GitHub issue

Bug report

When using NODE_OPTIONS='--inspect' next dev -p 1337 I’m still getting the error: Starting inspector on 127.0.0.1:9229 failed: address already in use

Describe the bug

From what I understand, this bug should have been fixed as of https://github.com/zeit/next.js/pull/11041.

However, I still get the error:

npm run dev

> frontend@0.1.0 dev 
> NODE_OPTIONS='--inspect' next dev -p 1337

Debugger listening on ws://127.0.0.1:9229/90c3d543-273f-492c-a8f6-bb3afd978e64
For help, see: https://nodejs.org/en/docs/inspector
[ wait ]  starting the development server ...
[ info ]  waiting on http://localhost:1337 ...

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

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

  1. Edit package.json’s dev script:
 "scripts": {
    "dev": "NODE_OPTIONS='--inspect' next dev -p 1337",
    ...
  },
  "dependencies": {
    "next": "9.3.4",
    ...
  },
  1. npm run dev or yarn dev
  2. See error
npm run dev

> frontend@0.1.0 dev 
> NODE_OPTIONS='--inspect' next dev -p 1337

Debugger listening on ws://127.0.0.1:9229/90c3d543-273f-492c-a8f6-bb3afd978e64
For help, see: https://nodejs.org/en/docs/inspector
[ wait ]  starting the development server ...
[ info ]  waiting on http://localhost:1337 ...

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

Expected behavior

Do not see address already in use error

Screenshots

If applicable, add screenshots to help explain your problem.

System information

  • OS: macOS
  • Browser (if applies) [e.g. chrome, safari]
  • Version of Next.js: 9.3.4 (also tried on 9.3.5-canary.7)
  • Version of Node.js: 12.16.2

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:3
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
Janpotcommented, May 19, 2020

The conflicting port comes from fork-ts-checker-webpack-plugin which starts its childprocess with the same environment variables as the host process. I opened https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/pull/405 to get around this. You can also use

NODE_OPTIONS='--inspect=0'

to assign a random port. You’ll have to manually configure devtools with this port afterwards though.

edit:

Looks like fork-ts-checker-webpack-plugin isn’t used during next dev anymore, so this shouldn’t be a problem anymore

3reactions
PeoBcommented, Apr 12, 2020

Had same issue, tried with 9.3.4 and 9.3.5-canary.7.

Ended up simply doing node --inspect node_modules/next/dist/bin/next dev which seems to do the trick for me

Read more comments on GitHub >

github_iconTop Results From Across the Web

Still getting 'address already in use' using --inspect ... - GitHub
Bug report When using NODE_OPTIONS='--inspect' next dev -p 1337 I'm still getting the error: Starting inspector on 127.0.0.1:9229 failed: ...
Read more >
Nodemon Inspect address already in use when refresh with ...
I am debugging a node application in Visual Studio, so I have to attach create a new configuration in launch.json:
Read more >
TypeScript debugging with Visual Studio Code
Visual Studio Code supports TypeScript debugging through its built-in Node.js ... file in a .vscode folder with default values detected in your project....
Read more >
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 >
Create an ASP.NET Core app with TypeScript - Visual Studio
In this tutorial, you create an app using ASP. ... If you need to install the workload but already have Visual Studio, go...
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