To attach VS Code to a process already running on your Mac, use the debugger that supports that process’s language: for Node.js, choose Attach to Node Process from the Command Palette; for C#, choose Debug: Attach to a .NET 5+ or .NET Core process; for C/C++, create an attach configuration using LLDB or GDB. These routes are specific to the runtime or extension. There is no single VS Code command that attaches to every kind of process.
Before you attach: identify the process and debugger
First identify what the process runs: Node.js, .NET, native C/C++, or another runtime. VS Code’s built-in Node debugger and its language extensions provide different attach features; a process appearing in macOS Activity Monitor does not mean every debugger can attach to it. You also need the matching extension for the language. For native C/C++ on macOS, Microsoft documents LLDB or GDB support through the C/C++ extension. VS Code: Debug C++
Open the project or source files that correspond to the running program. Attaching connects the debugger to a process; it does not start the app, rebuild it, or guarantee that breakpoints can bind. Matching source and available debug symbols matter, especially for native programs and optimized builds.
Attach to a running Node.js process
In VS Code, press ⇧⌘P to open the Command Palette, run Debug: Attach to Node Process, and select the intended process from the Quick Pick. The picker lists candidate processes and shows their process IDs and debug ports. VS Code documents this route for Node processes that were not started in debug mode as well as processes using an inspect option. VS Code: Node.js debugging
If the process is not listed, or you want a repeatable configuration, open or create .vscode/launch.json and add an attach configuration. For a process already running without debug mode, use the process ID picker variable:
{
"name": "Attach to Node process",
"type": "node",
"request": "attach",
"processId": "${command:PickProcess}"
}
Select this configuration in Run and Debug, then start debugging with F5. For a Node process already started with --inspect, use an attach configuration with its debug port instead; Node’s default is 9229. Don’t combine processId and port: VS Code determines the port automatically when attaching by process ID. Node.js debugging configuration details
Attach to a running .NET process
Install the Microsoft C# extension and open the Command Palette with ⇧⌘P. Run Debug: Attach to a .NET 5+ or .NET Core process, then select the target process from the list. This is the documented process-attach route for C# in VS Code; use it instead of assuming Node’s process picker or configuration fields apply to .NET. VS Code: C# debugging
After attaching, set a breakpoint in the matching source and let the application reach that code. If the breakpoint stays unbound, check that the process is running the build corresponding to the source you opened and that usable symbols are available. The C# debugger’s exact-source setting and symbol options can affect debugging, and attaching cannot retroactively change how already-loaded modules were compiled. C# debugger settings
Attach to a native C or C++ process
Install the Microsoft C/C++ extension and use an attach configuration in .vscode/launch.json. The configuration needs the executable path so the debugger can load symbols, an attach request, and a process ID. The C/C++ configuration reference documents ${command:pickProcess} as the default process picker and LLDB as an available debugger on macOS. C/C++ launch configuration reference
A minimal macOS configuration shape is:
{
"name": "Attach to native process",
"type": "cppdbg",
"request": "attach",
"program": "${workspaceFolder}/path/to/executable",
"processId": "${command:pickProcess}",
"MIMode": "lldb"
}
Replace path/to/executable with the actual executable used by the running process. Keep MIMode set to lldb for this LLDB example; GDB has separate setup requirements on macOS. The debugger needs the executable location to load symbols, so a guessed or unrelated path can leave source-level debugging unusable. C/C++ configuration reference
If attach fails or breakpoints do not hit
Check that you selected the correct process, the relevant extension is installed, and the process and debugger have compatible architectures. On Apple silicon, architecture mismatches are specifically documented as a possible cause of C# attach errors. For C/C++, confirm that the executable path and available symbols match the running build. If the process belongs to another user or is protected by macOS, operating-system permissions can also prevent attachment; use an authorized process and follow the applicable macOS security policy rather than trying to bypass it.
For Node.js, use the language-specific process picker or configure the inspect port; a generic C/C++ attach configuration is not a substitute. For C#, use the .NET attach command. For native C/C++, use cppdbg with LLDB or a separately configured GDB installation. These distinctions help narrow the next step when a generic “attach” instruction does not fit the target.
When finished, use Debug: Stop to disconnect. In Node.js attach mode, VS Code says stopping disconnects the debugger and the target continues running. Confirm your extension’s behavior for other runtimes if keeping the process alive is important; attach and launch sessions do not necessarily have identical stop behavior. VS Code: Node.js debugging
Sources
Node.js debugging in VS Code — Microsoft
Debugging — Microsoft
List of configurable options — Microsoft
Configure C/C++ debugging — Microsoft
Debug C++ in Visual Studio Code — Microsoft