Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use debugpy in VScode to debug remote python server?

I've used "type": "python" to debug remote python servers. Now I'm seeing this warning in launch.json:

This configuration will be deprecated soon. Please replace python with debugpy to use the new Python Debugger extension.

enter image description here

My original setting:

{
      "type": "python",
      "request": "attach",
      "name": "attach remote",
      "host": "192.168.1.101",
      "port": 8765,
      "pathMappings": [
        {
          "localRoot": "${workspaceFolder}/...",
          "remoteRoot": "/usr/app/..."
        }
      ],
      "justMyCode": false
    },

When I switch to "type": "debugpy" I get the following error on the "port" and "host" fields:

Property port is not allowed.

enter image description here

So the question is: how to add the port and host information to complete the migration of the debug configuration?

like image 309
PeterKogan Avatar asked Sep 02 '26 16:09

PeterKogan


1 Answers

So it turns out it's pretty easy: replace the "port" and "host" attributes with "connect", so if your configuration was:

{
      "type": "python",
      "request": "attach",
      "name": "attach remote",
      "host": "192.168.1.101",
      "port": 8765,
      "pathMappings": [
        {
          "localRoot": "${workspaceFolder}/...",
          "remoteRoot": "/usr/app/..."
        }
      ],
      "justMyCode": false
    },

It becomes:

{
      "type": "debugpy",
      "request": "attach",
      "name": "attach remote",
      "connect": { "host": "192.168.1.101", "port": 8765 },
      "pathMappings": [
        {
          "localRoot": "${workspaceFolder}/...",
          "remoteRoot": "/usr/app/..."
        }
      ],
      "justMyCode": false
    },
like image 60
PeterKogan Avatar answered Sep 04 '26 09:09

PeterKogan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!