How do I debug remote applications with VS Code?
Jul 06, 2025 am 01:34 AMIt is feasible and easy to debug remote applications using VS Code. The key is to connect local VS Code to the remote environment for remote editing and debugging. 1. Install Remote - SSH extension and connect to the remote host through SSH; 2. Start the debug mode of the application on the remote side and open the corresponding port; 3. Configure the launch.json file to set debug parameters such as type, port and path; 4. Set breakpoints in VS Code and debug the application normally. The entire process is smooth and efficient, suitable for debugging applications running in remote environments.
Debugging remote applications with VS Code is totally doable and not as complicated as it might sound. The key idea is to connect your local VS Code instance to a remote environment—like a server or container—so you can edit and debug code directly on that remote system, while still working from the comfort of your local machine.
Here's how to actually pull it off.
1. Set Up Remote Development in VS Code
Before debugging, you need to be connected to the remote environment. VS Code has an official extension called Remote - SSH (and others like Remote - Containers or Remote - WSL) that makes this easy.
- Install the Remote - SSH extension from the Extensions panel.
- Once installed, you'll see a new icon in the bottom-left corner of VS Code (looks like two computer screens connected by a plug).
- Click that icon and choose "Connect to Host..." , then enter the SSH address, username, and password or private key for the remote server.
After connecting, VS Code will open a new window pointing to the remote file system. From here, you're essentially working on the remote machine.
2. Prepare Your Application for Debugging
Different languages ??require different setups, but the general idea is the same: make sure your app runs in debug mode and listens on the correct port.
For example:
- Node.js : Start your app with
node --inspect-brk -r ts-node/register ./src/index.ts
if using TypeScript. - Python : Use
python -m debugpy --listen 5678 --wait-for-client app.py
to launch in debug mode. - Other languages ??: Check documentation for their debugger equivalents.
Make sure the port used for debugging (like 5678 or 9229) is open and accessible on the remote machine. You may also need to configure firewall rules or cloud instance settings to allow traffic on that port.
3. Configure launch.json
for Remote Debugging
Once you're connected to the remote machine and have your app running in debug mode, set up your debugging configuration locally.
- In VS Code, go to the Run and Debug sidebar (
Ctrl Shift D
or click the bug icon). - Create a
launch.json
file if you don't already have one. - Add a new configuration that matches your runtime. Here's a basic Node.js example:
{ "version": "0.2.0", "configurations": [ { "type": "node", "request": "attach", "name": "Attach to Remote Node", "runtimeExecutable": "nodemon", "restart": true, "console": "integratedTerminal", "internalConsoleOptions": "neverOpen", "remoteRoot": "/home/your-user/path-to-app" } ] }
If you're using Python, use "type": "python"
and specify the host and port:
{ "name": "Python: Attach", "type": "python", "request": "attach", "host": "localhost", "port": 5678 }
Make sure the paths match what's on the remote machine. Also, double-check that the port number matches what your app is listening on.
4. Start Debugging Like Normal
Once everything is configured:
- Set breakpoints in your code by clicking the left margin next to line numbers.
- Trigger the part of your app that hits those lines (eg, send an API request or run a command).
- VS Code should pause execution at your breakpoints, letting you inspect variables, step through code, etc.
A few tips:
- Use the integrated terminal inside VS Code to manage your app processes.
- If things get stuck, restart the debugging session or kill/restart the process on the remote side.
- Make sure only one debugger is attached at a time to avoid conflicts.
This setup works surprisingly well once it's all lined up. It's especially handy for debugging apps running in staging or production-like environments without having to replicate everything locally.
Basically that's it.
The above is the detailed content of How do I debug remote applications with VS Code?. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

The differences in pricing, licensing and availability of VisualStudio and VSCode are as follows: 1. Pricing: VSCode is completely free, while VisualStudio offers free community and paid enterprise versions. 2. License: VSCode uses a flexible MIT license, and the license of VisualStudio varies according to the version. 3. Usability: VSCode is supported across platforms, while VisualStudio performs best on Windows.

VisualStudio is suitable for large projects, VSCode is suitable for projects of all sizes. 1. VisualStudio provides comprehensive IDE functions, supports multiple languages, integrated debugging and testing tools. 2.VSCode is a lightweight editor that supports multiple languages ??through extension, has a simple interface and fast startup.

SublimeText is suitable for developers who pursue speed and simplicity, while VSCode is suitable for users who need strong scalability and integration capabilities. 1.SublimeText is known for its lightweight and fast response, with GotoAnything and multi-select powerful. 2. VSCode is known for its scalability and IDE functions, with built-in Git and debugging tools, and IntelliSense improves development efficiency.

The most common method to open a VSCode integrated terminal is to use keyboard shortcuts. By default, press Ctrl (backtick key) to open or focus the terminal panel; Mac users usually use Cmd. If the shortcut keys do not work, which may be a keyboard layout or custom settings issue, you can check or change it in Keyboard Shortcuts under the File menu. In addition, you can switch the terminal panel by opening it in the top menu "Terminal>New Terminal" or clicking the terminal icon in the activity bar on the left. If the icon is not displayed, right-click the activity bar and make sure "Terminal" is checked. You can also right-click in the editor tab and select "Open in Integration Terminal" to run the command in the directory where the current file is located or the project root directory. This method is suitable for execution.

The best way to make batch modifications in VSCode is to use the Find and Replace feature. 1. Use "Find and Replace" in a single file: Press Ctrl H to open the panel, enter the search and replace content, and click "Replace" or "Replace All". 2. Search across multiple files: Press Ctrl Shift F to open the search tab, expand the replacement section, and select the replacement operation for a single file or entire project. 3. Use advanced options: such as case sensitivity, full word matching and regular expressions for more precise control, such as matching numbers with \d or using capture groups for complex replacements. This feature significantly improves code maintenance efficiency through fast and precise editing.

TodownloadandinstallVisualStudioCode,firstchecksystemrequirements—Windows10 (64-bit),macOS10.13 ,ormodernLinuxdistributions—thenvisittheofficialwebsitetodownloadthecorrectversionforyourOS,andfollowinstallationstepsspecifictoyourplatform.Beginbyensuri

TopullchangesfromaremoteGitrepositoryinVSCodewithoutusingtheterminal,useoneofthreemethodsstartingwithaccessingtheSourceControlsidebar.1.OpentheSourceControlsidebar(Ctrl Shift G),clickthethreedots(...),andselect"Pull".2.Usethestatusbarbyclic

To use VSCode for Java development, you need to install the necessary extensions, configure the JDK and set up the workspace. 1. Install JavaExtensionPack, including language support, debugging integration, build tools and code completion functions; optional JavaTestRunner or SpringBoot extension package. 2. Install at least JDK17 and verify through java-version and javac-version; set the JAVA_HOME environment variable, or switch multiple JDKs in the status bar at the bottom of VSCode. 3. After opening the project folder, make sure the project structure is correct and enable automatic saving, adjust the formatting rules, enable code checking, and configure the compilation task to optimize the opening.
