I have resolved this issue. If anyone wants to do remote development and debugging, follow below steps:

  1. Install remote ssh extension in VS code
  2. Once installed, you will find a green icon on the bottom left corner in vs code which allows us to connect to the remote machine.
  3. Connect to the remote machine using the standard ssh command. Alternatively, you can use ssh-keygen to generate a public-private key if you don't want to use the password at every prompt.
  4. Once you are connected to remote machine, you can open the file explorer and create any python file. When you will save this, it will get saved in your remote machine. This way you are using your machine to remotely develop code on another remote machine.
  5. Good thing about vs code is that it selects the remote machine's python interpreter so all the packages which you have installed on your remote machine will work with IntelliSense.
  6. In order to debug the code, we will use debugpy. Install this on both machine (remote & local)
  7. On your remote machine, run below command:

python3 -m debugpy --listen 1.2.3.4:5678 --wait-for-client app.py

here 1.2.3.4 is the IP of remote machine. This will start a remote debugger which will wait for a clients connection.

  1. On your local machine, in VS code open Run & Debug, add a configuration of Python: Remote Attach. Make sure that launch.json has the host as the IP of your remote machine and port as 5678.
  2. Now start debugging as normal and you will notice the code will break at first breakpoint and from here you can proceed normally as we used to do in local debugging process.

TBH, this is best feature VS code has because most of the software allows you to do remote development which is nothing but just a normal SSH but remote debugging gives you more control. I was doing some python project on Raspberry Pi and obviously cannot install VS code or pycharm on it. But with this feature now I can easily develop the code using Pi's python interpreter and debug it as well.

If anyone is having any issues, let me know. Happy to help.

Answer from S Andrew on Stack Overflow
🌐
Visual Studio Code
code.visualstudio.com › docs › python › debugging
Python debugging in VS Code
November 3, 2021 - This starts the package myproject using python3, with the remote computer's private IP address of 1.2.3.4 and listening on port 5678 (you can also start the remote Python process by specifying a file path instead of using -m, such as ./hello.py). Local computer: Only if you modified the source code on the remote computer as outlined above, then in the source code, add a commented-out copy of the same code added on the remote computer. Adding these lines makes sure that the source code on both computers matches line by line. #import debugpy # Allow other computers to attach to debugpy at this IP address and port.
Top answer
1 of 4
19

I have resolved this issue. If anyone wants to do remote development and debugging, follow below steps:

  1. Install remote ssh extension in VS code
  2. Once installed, you will find a green icon on the bottom left corner in vs code which allows us to connect to the remote machine.
  3. Connect to the remote machine using the standard ssh command. Alternatively, you can use ssh-keygen to generate a public-private key if you don't want to use the password at every prompt.
  4. Once you are connected to remote machine, you can open the file explorer and create any python file. When you will save this, it will get saved in your remote machine. This way you are using your machine to remotely develop code on another remote machine.
  5. Good thing about vs code is that it selects the remote machine's python interpreter so all the packages which you have installed on your remote machine will work with IntelliSense.
  6. In order to debug the code, we will use debugpy. Install this on both machine (remote & local)
  7. On your remote machine, run below command:

python3 -m debugpy --listen 1.2.3.4:5678 --wait-for-client app.py

here 1.2.3.4 is the IP of remote machine. This will start a remote debugger which will wait for a clients connection.

  1. On your local machine, in VS code open Run & Debug, add a configuration of Python: Remote Attach. Make sure that launch.json has the host as the IP of your remote machine and port as 5678.
  2. Now start debugging as normal and you will notice the code will break at first breakpoint and from here you can proceed normally as we used to do in local debugging process.

TBH, this is best feature VS code has because most of the software allows you to do remote development which is nothing but just a normal SSH but remote debugging gives you more control. I was doing some python project on Raspberry Pi and obviously cannot install VS code or pycharm on it. But with this feature now I can easily develop the code using Pi's python interpreter and debug it as well.

If anyone is having any issues, let me know. Happy to help.

2 of 4
4

It is frustrating there are so many out-dated instructions how to remote debug Python scripts from VSC.

As of August 2024 there is a far easier way to set this up that answers the OP's question which involved VSC being installed on a laptop and debugging a Python script saved on a Raspberry Pi also in the same LAN.

Once you have installed the Remote SSH extension on your local machine use that to SSH via VSC in to your remote machine. Now install the Python Debugger extension on your remote system.

Since you have ssh'd in to that remote system via the VSC extension VSC just debugs the script on that remote system as though it is LOCAL.

  1. Place a breakpoint (red dot) on the line you want script execution to stop at.
  2. From File Menu > Run > Start Debugging (F5)... The Command Palette will open and it will say:
  3. Select Debugger <-- Choose Python Debugger
  4. Then choose...
  5. Python File Debug the currently active Python File.
  6. Now use F10, F11 etc to step through the lines of code.

You DO NOT need to...

  • Do ssh local port forwarding.
  • Separately install debugpy from the command line in your local and remote environments.
  • Run debugpy from the command line.
  • Have a copy of the Python script in your local environment AND another on the remote environment. You only need ONE copy in the remote environment.
  • You don't even need a launch.json.

I checked about what sockets were opened by separately ssh'ing from a Terminal in to the "remote system" (my Raspberry Pi running Ubuntu) and they are all localhost.

ubuntu@ubuntu:~$ lsof -i
COMMAND     PID   USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
code-f1e1 76603 ubuntu    9u  IPv4 519530      0t0  TCP localhost:43675 (LISTEN)
code-f1e1 76603 ubuntu   12u  IPv4 519534      0t0  TCP localhost:43675->localhost:34540 (ESTABLISHED)
python    77190 ubuntu    4u  IPv4 520559      0t0  TCP localhost:39819 (LISTEN)
python    77190 ubuntu    8u  IPv4 522535      0t0  TCP localhost:45381 (LISTEN)
python    77190 ubuntu    9u  IPv4 521557      0t0  TCP localhost:45381->localhost:59082 (ESTABLISHED)
python    77190 ubuntu   11u  IPv4 521558      0t0  TCP localhost:35979->localhost:37454 (ESTABLISHED)
python    77218 ubuntu    3u  IPv4 520157      0t0  TCP localhost:37454->localhost:35979 (ESTABLISHED)
python    77228 ubuntu    3u  IPv4 520164      0t0  TCP localhost:59082->localhost:45381 (ESTABLISHED)
Discussions

How to "develop locally, run/debug remotely" for Python?
First, do you really need to develop locally? Vscode works very well over ssh or in a dev container. Dev containers have a learning curve, but ssh is very quick to get started with. Apart from those options, you can probably do what you need with a .vscode/launch.json file in your project. https://code.visualstudio.com/docs/python/debugging Let code completion help you with setting up that file. I have not done this myself, fwiw. I do my remote development in a dev container. To the debugger, my code is running locally, or as a separate process on the same host. When I debug code in a different container, I connect to that process over TCP, so we know that works; you may get a result by forwarding port 5678 over ssh. You'll need to setup how the local and remote paths map to each other. More on reddit.com
🌐 r/vscode
4
2
March 26, 2021
visual studio code - Setting up Python remote debugging in VSCode - Stack Overflow
I am having my remote(ubuntu 16.04) drive mounted on my local system(ubuntu 16.04) so that I can edit the source files by opening them in vscode. Also, in the integrated terminal I can ssh to remote More on stackoverflow.com
🌐 stackoverflow.com
Remote debugging configuration suddenly not working anymore
So, I found out after some various tests that it was a problem with the vscode-python extension. Specifically, version 2019.4.12954 breaks the debugging functionality (cannot add Python debug configs for instance) and also seriously messes with the how the settings look when pressing Ctrl+Shift+P. Rolling back to version 2019.4.11987 solves the issue, strangely enough. More on reddit.com
🌐 r/vscode
3
7
May 12, 2019
Debugging dockerized Python apps in VSCode
I find it easiest to just call breakpoint() in my code and use the docker attach command to drop into the command line debugger. No extra setup. And you can improve the command line experience with pdbpp or ipdb. More on reddit.com
🌐 r/Python
20
126
December 23, 2023
🌐
DEV Community
dev.to › suzuki0430 › mastering-python-debugging-on-remote-ssh-with-vscode-4lg7
Mastering Python Debugging on Remote SSH with VSCode - DEV Community
May 26, 2023 - To remote debug, you need to connect to debugpy on the remote machine from the local machine. To do this, use SSH tunneling with the following command (linking port 5678 of the local machine with port 5678 of the remote machine).
🌐
Donjayamanne
donjayamanne.github.io › pythonVSCodeDocs › docs › debugging_remote-debugging
Remote Debugging | Python in Visual Studio Code
{ "name": "Attach (Remote Debug)", "type": "python", "request": "attach", "localRoot": "${workspaceRoot}", "remoteRoot": "C:/temp/myscripts", "port": 3000, "secret": "my_secret", "host":"ipaddress or 'localhost'" }
🌐
Reddit
reddit.com › r/vscode › how to "develop locally, run/debug remotely" for python?
r/vscode on Reddit: How to "develop locally, run/debug remotely" for Python?
March 26, 2021 -

Hi r/vscode!

I'm relatively new to VS Code (and developing in general), so please forgive any egregious lapses in my knowledge.

How remote development worked in PyCharm

I come from PyCharm, where I could write Python scripts locally and run/debug them on a remote machine I had SSH access to. PyCharm would automatically sync my files to the remote server, so the latest version of my code was always on my local machine while any output generated would be on my remote machine.

I've tried to set this up in VS Code...

I've installed VS Code, the Python extension, the Remote-SSH extension, and the Sync-RSync extensions. When I write code locally, I've set Sync-Rsync to automatically sync my changes to the remote server every time I save, which is great! However, to run/debug my code remotely, I need to:

  • open a new VS Code window SSHed to my remote server

  • navigate to and open my workspace there

  • find the synced copy of the script I just edited

  • hit run/debug

Now I have two windows to manage, with their own files and workspaces! I often forget which machine I'm editing on and have to backtrack and copy changes manually across machines.

I'm sure I'm missing something trivial in my setup, but I'm not sure what. Could you please help? How do I write code in exactly one VS Code window (running locally) and run/debug it in a remote environment?

🌐
GitHub
github.com › uyuni-project › uyuni › wiki › Configuring-Remote-Python-Debugging-in-VSCode
Configuring Remote Python Debugging in VSCode
January 2, 2026 - For example, /usr/lib/venv-salt-minion/bin/pip install debugpy. After that, you can verify the debugpy import by executing /usr/lib/venv-salt-minion/bin/python3 -c 'import debugpy' && echo "success".
Author   uyuni-project
🌐
Microsoft Learn
learn.microsoft.com › en-us › visualstudio › python › debugging-python-code-on-remote-linux-machines
Debug Python code on remote Linux computers - Visual Studio (Windows) | Microsoft Learn
December 11, 2025 - Use Visual Studio to debug Python code running on remote Linux computers, including necessary configuration steps, security, and troubleshooting.
Find elsewhere
🌐
Super User
superuser.com › questions › 1786104 › visual-studio-code-and-debugpy-remote-debugging-client-authentication-failed
Visual Studio Code and Debugpy remote debugging - "Client Authentication Failed" Error - Super User
May 26, 2023 - Back on my workstation run the following launch configuration to VSCode: { "name": "Support Robot Debugging", "type": "python", "request": "attach", "connect" : { "port": 5678, "host": "localhost" }, "pathMappings": [ { "localRoot": "${workspaceFolder}", "remoteRoot": "." } ] } Receive this error: Error dialog stating: Client not authenticated.
🌐
GitHub
github.com › gloveboxes › Remote-debug-Python-on-Raspberry-Pi-from-Visual-Studio-Code
GitHub - gloveboxes/Remote-debug-Python-on-Raspberry-Pi-from-Visual-Studio-Code: How to debug Python app running on a Raspberry Pi from Visual Studio Code on Linux, Windows and macOS · GitHub
How to debug Python app running on a Raspberry Pi from Visual Studio Code on Linux, Windows and macOS - gloveboxes/Remote-debug-Python-on-Raspberry-Pi-from-Visual-Studio-Code
Starred by 6 users
Forked by 3 users
Languages   Python 90.6% | Shell 9.4%
🌐
Visual Studio Code
code.visualstudio.com › docs › containers › debug-python
Debug Python within a container
November 3, 2021 - { "version": "0.2.0", "configurations": [ { "name": "Debug Flask App", "type": "docker", "request": "launch", "preLaunchTask": "docker-run: debug", "python": { "pathMappings": [ { "localRoot": "${workspaceFolder}", "remoteRoot": "/app" } ], "projectType": "flask" }, "dockerServerReadyAction": { "action": "openExternally", "pattern": "Running on (http?://\\S+|[0-9]+)", "uriFormat": "%s://localhost:%s/" } } ] }
🌐
Visual Studio Code
code.visualstudio.com › docs › languages › python
Python in Visual Studio Code
November 3, 2021 - VS Code comes with great debugging support for Python via the Python Debugger extension, allowing you to set breakpoints, inspect variables, and use the debug console for an in-depth look at how your program is executing step by step.
🌐
GitHub
github.com › xuancong84 › python-remote-debug
GitHub - xuancong84/python-remote-debug: A tutorial on how to use VSCode to do Python remote debugging · GitHub
This is a tutorial on how to setup a convenient Python remote debugging (the debug server approach) for VSCode.
Author   xuancong84
🌐
Visual Studio Code
code.visualstudio.com › docs › debugtest › debugging
Debug code with Visual Studio Code
November 3, 2021 - The active session can be changed either by using the dropdown menu in the debug toolbar or by selecting a different element in the CALL STACK view. VS Code does not support built-in remote debugging across all languages.
🌐
Microsoft Developer Blogs
devblogs.microsoft.com › dev blogs › microsoft for python developers blog › remote python development in visual studio code
Remote Python Development in Visual Studio Code - Microsoft for Python Developers Blog
May 2, 2019 - You can then create files, edit code, open a WSL terminal, and debug just like the other remote development environments: We are excited for the capabilities this unlocks in Visual Studio Code for Python developers, to get started head over to the Visual Studio Code Remote docs, and/or try out some of our sample apps: ... Be sure to let us know of any issues or feedback on the remote extensions by filing issues on our vscode-remote-release GitHub page.
🌐
GitHub
github.com › microsoft › ptvsd
GitHub - microsoft/ptvsd: Python debugger package for use with Visual Studio and Visual Studio Code.
Python debugger package for use with Visual Studio and Visual Studio Code. - microsoft/ptvsd
Starred by 556 users
Forked by 69 users
Languages   Python 97.9% | C++ 1.7% | HTML 0.1% | PowerShell 0.1% | Shell 0.1% | C 0.1% | Python 97.9% | C++ 1.7% | HTML 0.1% | PowerShell 0.1% | Shell 0.1% | C 0.1%
🌐
LinkedIn
linkedin.com › pulse › python-remote-debugging-visual-studio-code-raspberry-pi-mircea-dogaru
Python Remote Debugging with Visual Studio Code and Raspberry Pi
June 2, 2020 - Fortunately there is a way to do development on your dedicated machine in Visual Studio Code and run that code remotely on the Pi with debugging capabilities, and all of that with just one click. ... a development machine. I use a Windows 10 desktop computer but can be any Linux/Windows laptop/desktop. Should work on MacOS too but I don't have one to try. OpenSSH. Comes preinstalled on Windows 10 and most Linux distros. Visual Studio Code. Python >=3.4.
🌐
Medium
medium.com › @husein2709 › vscode-debugging-for-python-your-ultimate-step-by-step-guide-711934c5c786
VSCode Debugging for Python: Your Ultimate Step-by-Step Guide
September 2, 2024 - VSCode supports remote debugging, allowing you to debug applications running on a different machine. It’s like having a long-distance debugging buddy. Setting Up Remote Debugging: Use the remote attribute in your launch.json configuration ...
🌐
Qodo
qodo.ai › blog › learn › tutorial: how to debug python code in visual studio code
Tutorial: How to Debug Python code in Visual Studio Code - Qodo
September 17, 2025 - Learn to debug Python in VS Code with breakpoints, real-time tracking, and advanced techniques for seamless coding.