Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio Code - debug by "Attach" does not work on Mac OS

I'm trying to debug my node js project on Mac. It works very well in "Launch" mode but not in "Attach" mode. In "Attach" mode, when I start debugging, I see VS Code first trying to start the debugger in seconds and then stop suddenly without showing any error message. I leave everything in their default values {"name": "Attached", "type": "node", "address": "localhost", "port":3000}, and I'm sure I'm running the site at http://localhost:3000

like image 863
Hung Nguyen Avatar asked Dec 10 '25 21:12

Hung Nguyen


1 Answers

I got the answer from MS Support Team, it works like a champ now :) Love VSCode and the team so much.

Below is the answer from Andre Weinand of VSCode Team:

In "Attach" mode the VSCode debugger needs to connect to the debug port of the node runtime, which by default uses the port 5858. The debugger can not work with "a site" that your node program is servicing.

So can you please make sure that you are launching your node program with the correct debugging arguments, e.g. node --debug-brk program.js or node --debug-brk=3000 program.js

The first uses the default port 5858 and you would have to modify the Attach launch config accordingly. The second changes the port to 3000 which should work with your Attach launch config.

like image 149
Hung Nguyen Avatar answered Dec 13 '25 11:12

Hung Nguyen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!