6

I am trying to debug my Discord bot using the DiscordJS lib. My trouble is that when I start a debug session (launching with vscode or with --inspect-brk | --debug-brk)

I get a Starting inspector on 127.0.0.1:42457 failed: address already in use error I have tried changing the port in both situations and still getting the same error on different ports. My bot is sharded so its start child process of itself. I have tried using vscode to attach to child processes but still the same error.

If anybody is familiar with DiscordJS and knows how to debug a sharded bot some help would be much appreciated

112madgamer
  • 185
  • 1
  • 2
  • 11
  • Are you starting the server bound to `127.0.0.1` or `localhost`? – weirdpanda Feb 11 '18 at 05:13
  • https://stackoverflow.com/a/49797588/222356 has a great answer on how to kill a process using a specific port. Killing all your node processes (per an answer below) is probably not a good idea. – ericsoco May 01 '20 at 17:30

3 Answers3

2

In my case to solve this, just add that config on nodemon.json

{
 "execMap": {
  "js": "node --inspect=9300 -r sucrase/register"
  }
}

I added --inspect=9300 to set port to this specific port

xbral
  • 91
  • 4
-1

First Ctrl C (or Cmd C) to quit all your progress in the cmd.

Start Task Manager > Find all tasks named "node" > End process.

Now go back to your cmd and start server.

-2

That is because you are already running that application in with node filename.js, hence stop that process and start with debugging again with same port.

You can take a look that on the below video might help

https://www.youtube.com/watch?v=b8e9RAekktY&t=28s

Mahesh G
  • 1,226
  • 4
  • 30
  • 57