While testing #20991:
Steps to Reproduce:
node --inspect --debug-brk server.js in shell with simple server.js code. {
"type": "node",
"protocol": "auto",
"request": "attach",
"name": "Attach to Process",
"address": "localhost",
"port": 9229
}
However, launching it in the "request": "launch" mode successfully defaults it to v7.5.0.
Expected Behaviour:
Determine the running version of inspector.
Before you attach, can you open http://localhost:9229/json/version in your browser? What do you see?
Were you connected to the internet when you tried this?
If you set "protocol": "inspector" does it work?
@roblourens Yes, I can open it. This is the data from the link:
{
"Browser": "node.js/v7.5.0",
"Protocol-Version": "1.1"
}
I was connected to the internet when I tried this.
"protocol": "inspector" works.
Is that the full data, like it's not an array?
@roblourens yes, it is the full data that I get on that link.
Ah, the format of /json/version is different in later node versions. Thanks
Hi,
I have the same problem. I have this configuration:
{
"type": "node",
"request": "attach",
"protocol": "auto",
"name": "Attach to Process",
"port": 5858
}
And this is the error message:
Debugging with legacy protocol because Node.js version could not be determined (Error: connect ECONNREFUSED 127.0.0.1:5858)
But I can't access to http://localhost:5858/json/version as it was asked to michelkaporin.
@MimoMoreno what version of node are you using and how are you starting node?
@weinand I'm using v6.0.0 and I'm trying to start the debugger from the debug panel (from the activity bar).
@MimoMoreno Your configuration from above does not launch "node". It tries to "attach" to a node process that is already running (that's the reason for the "attach" value of the "request" attribute). If node is not running, debugging will fail with the message you are seeing.
So either you'll have to launch node from the command line, e.g. node --debug-brk myProgram.js or you better use a configuration with request type "launch", e.g. something like this:
{
"type": "node",
"request": "launch",
"protocol": "auto",
"name": "Launch program",
"program": "myProgram.js"
}
This will launch your program with node and then attach the debugger to it.
BTW, node v6.0.0 is rather old. I suggest to use a more recent version that includes the recommended security fixes, e.g. v6.11.1 (LTS) or v8.2.1.
@weinand I'm sorry, I didn't put all my configuration. This is it:
{
"type": "node",
"request": "launch",
"protocol": "auto",
"name": "Launch Program",
"program": "${workspaceRoot}/app.js",
"cwd": "${workspaceRoot}"
},
{
"type": "node",
"request": "attach",
"protocol": "auto",
"name": "Attach to Process",
"port": 5858
}
But yet with this configuration I cannot start debugging mode.
We will soon upgrade to version 8!
@MimoMoreno these are two configurations. Which one are you using?
In case you don't know, this drop down menu shows the configuration you are using:

@weinand thanks for that tip! I was using the attach configuration. I changed it to launch program and it worked! So in which case would I use the attach to process configuration?
As I've explained above:
It tries to "attach" to a node process that is already running.
Example: you can launch your node program independent from VS Code from the command line, e.g. as a server process running silently in the background. Suddenly you notice that the server behaves strangely and you want to understand why. You launch VS Code and then run the "Attach to Process" config. Please note that this requires that your node program has been launched with the --debug argument since otherwise the debugger cannot attach to it.
BTW, as you could see now, your problem was completely unrelated to the problem described in this issue.
I suggest not to add a "me too" to another issue but instead create a new issue.
The "me toos" are just making issues difficult to read because one has always to skip around the unrelated discussions. And useful explanations (like mine from above), are now difficult to find because they are buried inside an unrelated issue.
Anyone coming to this thread in the future, I had ATTACH working on one project, and not the other. The difference between my two package.json files was I need the "main": "server.js". As soon as I added that, the debugger attached fine.
Most helpful comment
Anyone coming to this thread in the future, I had ATTACH working on one project, and not the other. The difference between my two package.json files was I need the "main": "server.js". As soon as I added that, the debugger attached fine.