# VS Code Debugger Not Attaching
You've set up your debug configuration, hit F5, and... nothing. The debug toolbar flickers and disappears, or you get an error like "Cannot connect to runtime process" or "Timeout waiting for debugger to connect". The debugger refuses to attach to your process, leaving you to debug with console.log statements.
Introduction
This article covers troubleshooting steps and solutions for VS Code Debugger Not Attaching - Complete Troubleshooting Guide. The error typically occurs in production environments and can cause service disruptions if not addressed promptly.
Symptoms
Common error messages include:
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "attach",
"name": "Attach to Node",
"port": 9229,
"address": "localhost",
"localRoot": "${workspaceFolder}",
"remoteRoot": null
}
]
}node --inspect app.js
# or with a specific port
node --inspect=9229 app.jspip install debugpy
python -m debugpy --listen 5678 app.pyCommon Causes
- Configuration misconfiguration
- Missing or incorrect credentials
- Network connectivity issues
- Version compatibility problems
- Resource exhaustion or limits
- Permission or access denied
Step-by-Step Fix
- 1.Check logs for specific error messages
- 2.Verify configuration settings
- 3.Test network connectivity
- 4.Review recent changes
- 5.Apply corrective action
- 6.Verify the fix
Understanding the Attachment Problem
Debugger attachment failures occur in three scenarios:
- 1.Launch attachment: VS Code starts your app and tries to attach
- 2.Process attachment: Connecting to an already-running process
- 3.Remote attachment: Connecting to a process on another machine
Each has different failure modes. Let's diagnose them systematically.
Step 1: Verify Your Launch Configuration
A misconfigured launch.json is the most common cause. Open your configuration:
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "attach",
"name": "Attach to Node",
"port": 9229,
"address": "localhost",
"localRoot": "${workspaceFolder}",
"remoteRoot": null
}
]
}Critical checks:
- type: Must match your runtime (node, python, go, etc.)
- port: Must match the port your app is listening on
- address: Should be
localhostfor local, IP for remote - request: Use "attach" for running processes, "launch" for starting new
Step 2: Verify the Process Is Listening
Before VS Code can attach, your application must be listening for debug connections.
For Node.js:
``bash
node --inspect app.js
# or with a specific port
node --inspect=9229 app.js
For Python:
``bash
pip install debugpy
python -m debugpy --listen 5678 app.py
For Go:
``bash
dlv debug --headless --listen=:2345 --api-version=2
Verify the port is open: ```bash # Linux/macOS lsof -i :9229
# Windows netstat -ano | findstr :9229 ```
If nothing is listening, your app isn't running in debug mode.
Step 3: Fix Port Conflicts
If another process is using your debug port:
```bash # Find what's using the port # Linux/macOS lsof -i :9229
# Windows netstat -ano | findstr :9229 ```
Either kill the conflicting process or change your debug port:
``json
{
"type": "node",
"request": "attach",
"name": "Attach to Node",
"port": 9230 // Changed from 9229
}
Step 4: Resolve Firewall and Network Issues
The debugger needs to communicate through local network interfaces.
Windows Firewall:
``powershell
# Check if Node.js is allowed
netsh advfirewall firewall show rule name="Node.js Server"
Add a rule if needed:
``powershell
netsh advfirewall firewall add rule name="VS Code Debug" dir=in action=allow protocol=TCP localport=9229
macOS: Check "Allow incoming connections" for VS Code in System Preferences > Security & Privacy > Firewall.
Linux (ufw):
``bash
sudo ufw allow 9229/tcp
Step 5: Fix Timeout Issues
Slow startup or network latency causes timeouts. Increase the timeout:
{
"type": "node",
"request": "attach",
"name": "Attach to Node",
"port": 9229,
"timeout": 30000, // 30 seconds
"restart": true,
"stopOnEntry": false
}The default timeout is often too short for complex applications.
Step 6: Handle Docker and Container Attachment
Debugging in containers requires special configuration:
Docker Node.js example:
``json
{
"type": "node",
"request": "attach",
"name": "Attach to Docker",
"port": 9229,
"address": "localhost",
"localRoot": "${workspaceFolder}",
"remoteRoot": "/app",
"sourceMapPathOverrides": {
"/app/*": "${workspaceFolder}/*"
}
}
Docker run command:
``bash
docker run -p 9229:9229 your-image node --inspect=0.0.0.0:9229 app.js
Note 0.0.0.0 binding - it must bind to all interfaces, not just localhost.
Step 7: Fix Source Map Issues
If you're debugging transpiled code (TypeScript, bundled JS), source maps must be correct:
TypeScript tsconfig.json:
``json
{
"compilerOptions": {
"sourceMap": true,
"sourceRoot": "/",
"mapRoot": "./dist"
}
}
Webpack:
``javascript
module.exports = {
devtool: 'source-map',
// ...
};
Launch configuration for source maps:
``json
{
"type": "node",
"request": "launch",
"name": "Debug TypeScript",
"runtimeExecutable": "node",
"runtimeArgs": ["--nolazy", "-r", "ts-node/register"],
"args": ["${workspaceFolder}/src/index.ts"],
"sourceMaps": true,
"outFiles": ["${workspaceFolder}/dist/**/*.js"],
"resolveSourceMapLocations": [
"${workspaceFolder}/**",
"!**/node_modules/**"
]
}
Verification
Test that debugging works:
- 1.Set a breakpoint on an executable line
- 2.Start debugging (F5)
- 3.The breakpoint should show as a filled red circle (not hollow)
- 4.Trigger the code path
- 5.Execution should pause at the breakpoint
- 6.Variables panel should show local variables
If breakpoints show as gray circles, they're not bound - usually a source map issue.
Common Error Messages Decoded
| Error | Cause | Solution |
|---|---|---|
| "Cannot connect to runtime" | Wrong port or not listening | Verify debug port and startup command |
| "Timeout waiting for debugger" | Slow startup | Increase timeout, check network |
| "Unable to set breakpoint" | Source map mismatch | Rebuild source maps, check paths |
| "Process not found" | PID changed or process exited | Refresh process list |
| "Address already in use" | Port conflict | Kill process or change port |
Debugger attachment issues are almost always configuration problems. Start by verifying the port and working outward to source maps and network issues.
Related Articles
- [VS Code Auto Save Not Working](fix-vscode-auto-save)
- [VS Code Bracket Colorization Not Working](fix-vscode-bracket-colorization)
- [Fix Fix Vscode Copilot Not Working Issue in VS Code](fix-vscode-copilot-not-working)
- [Fix VS Code Debugging Not Stopping at Breakpoints: Breakpoints Ignored](fix-vscode-debugging-breakpoints-not-working)
- [Fix Fix Vscode Dev Container Build Issue in VS Code](fix-vscode-dev-container-build)
<script type="application/ld+json"> { "@context": "https://schema.org", "@type": "TechArticle", "headline": "VS Code Debugger Not Attaching - Complete Troubleshooting Guide", "description": "Resolve VS Code debugger attachment failures. Fix launch configurations, port conflicts, and process attachment issues for Node.js, Python, and more.", "url": "https://www.fixwikihub.com/fix-vscode-debugger-not-attaching", "publisher": { "@type": "Organization", "name": "FixWikiHub", "url": "https://www.fixwikihub.com" }, "author": { "@type": "Person", "name": "FixWikiHub Editorial Team" }, "datePublished": "2025-11-24T10:34:22.796Z", "dateModified": "2025-11-24T10:34:22.796Z" } </script>