When developing web applications in VS Code (Visual Studio Code), you might encounter issues with VS Code unable to launch browser instances, which prevents you from testing and debugging the code. Typically, the error presents itself with a message such as “VS Code unable to attach to browser” when you try to run the code. Fortunately, there are a few straightforward troubleshooting methods to try and resolve the issue.
Contents
Quick Fixes for VS Code Browser Launch Problems

Before diving into configuration changes, go through this checklist of quick fixes:
- Save the code and restart the application, then try launching the browser again.
- Temporarily disable browser extensions, which might interfere with VS Code connections.
- Remove recently installed VS Code extensions to check if they aren’t causing the error.
- Ensure no other development servers are running on the same port.
- Clear your browser’s cache and cookies.
- Check if you have the latest version of VS Code.
Fix 1 – Configure Default Browser Settings in VS Code
In some odd cases, VS Code might be attempting to run on a server that’s not your default one, which can bring up issues.
Step 1. Open VS Code Settings with “Ctrl + ,” (or “Cmd + ,” on Mac).
Step 2. Search for “browser” in the search bar.
Step 3. Look for the setting “Live Server > Settings: Custom Browser” or similar browser-related settings depending on your extensions.
Step 4. Ensure the browser path is correctly set. For Chrome on Windows, this will look something like: C:\Program Files\Google\Chrome\Application\chrome.exe
Step 5. Alternatively, check “Live Server > Settings: Browser” and set it to your preferred browser (such as Chrome, Firefox, Edge, etc.).
Step 6. Apply the changes and restart VS Code.
Fix 2 – Fix VS Code Unable to Attach to Browser During Debugging by Changing the JSON File
When VS Code unable to attach to browser occurs during debugging sessions, it’s often related to debugging configuration, which is in a separate JSON file.
Step 1. Open your project’s .vscode/launch.json file. If it doesn’t exist, create it by going to the “Run and Debug” panel (with “Ctrl + Shift + D”) and clicking “create a launch.json file.”
Step 2. Ensure your debugging configuration includes the correct browser and port settings. For Chrome, this will look like:
{
“version”: “0.2.0”,
“configurations”: [
{
“type”: “chrome”,
“request”: “launch”,
“name”: “Launch Chrome”,
“url”: “http://localhost:3000”,
“webRoot”: “${workspaceFolder}”
}
]
}
Step 2b. For Chrome debugging, ensure you’re not running Chrome with any security flags that might block VS Code attachment. Additionally, try adding the following configuration line:
“runtimeArgs”: [“–disable-web-security”, “–user-data-dir=${workspaceFolder}/.chrome”]
Step 3. Save the file.
Step 4. Close all browser instances completely before starting a debugging session.
If you’re not using Chrome, you need to ensure that the JSON file contains the right “type” for the browser you’re using. For Edge, this will be “edge” or “pwa-msedge.” Alternatively, you can use the “Debugger for Firefox” extension and change the type to “firefox.”
Fix 3 – Change Admin Permissions for VS Code
In some odd cases, administrative access to VS Code and browsers can cause the issue. For some users, unchecking the “Run with administrative permissions” box on the VS Code Properties (for the shortcut, for example) has solved the issue. This seems to apply to Edge and Chrome (or other Chromium-based browser). An alternative would be to change the browser to Firefox or another non-Chromium browser.



