How does your adapter definition look like? debugpy is a bit special in regards to the attach handling. For most adapters you still launch the debug-adapter the same way, and then the debug-adapter attaches to the process. For debugpy the process using debugpy.listen() (or when using python -m debugpy --listen ...) launches the service that speaks DAP.

Because of that you'll need to switch over to a adapter definition of type server. I'd recommend to use nvim-dap-python which does that:

https://github.com/mfussenegger/nvim-dap-python/blob/d4400d075c21ed8fb8e8ac6a5ff56f58f6e93531/lua/dap-python.lua#L130-L153

🌐
GitHub
github.com › HiPhish › debugpy.nvim
GitHub - HiPhish/debugpy.nvim: Command and configuration frontend for Debugpy and nvim-dap · GitHub
Thin and hackable frontend command to nvim-dap and Debugpy for debugging Python code in Neovim.
Starred by 29 users
Forked by 3 users
Languages   Lua 64.3% | Vim Script 22.4% | Python 13.3%
🌐
John Tobin
johntobin.ie › blog › debugging_in_neovim_with_nvim-dap
Debugging in Neovim with nvim-dap · John Tobin
October 30, 2024 - https://github.com/mfussenegger/nvim-dap-python provides config for debugging individual tests. You need to install https://github.com/microsoft/debugpy and configure nvim-dap-python with the path to a Python binary that can import debugpy.
Discussions

Attach to debugpy
I'm trying to attach to a debugpy server started by the python process itself but can't get it working for some reason. I'm pretty new to this so probably doing something wrong and was ... More on github.com
🌐 github.com
2
1
debugpy.nvim: Command and API frontend to nvim-dap and Debugpy (debugging Python)
this is great will definitely give that a look. btw, do you have your own nvim dotfiles? would love to see people's debugging config. feels like mine is so half baked. More on reddit.com
🌐 r/neovim
8
22
December 17, 2021
Debugpy + Nvim-DAP in a Docker container - help getting this to work?
I’ve been trying to get Debugpy working with Nvim-DAP from inside a Docker container. I think I am close, but it’s not really working yet. Here is my setup: GitHub - gwerbin/debugpy-in-docker at 0c0db5ff05d36b94ce1fb969e6b6a1295b26292c I perform these steps: Open the runtime/service.py ... More on neovim.discourse.group
🌐 neovim.discourse.group
1
0
May 12, 2021
debugging - Configuring nvim-dap for JavaScript and Python - Stack Overflow
I'm looking to set up nvim-dap and followed the instructions for implementing it with Python and JavaScript, which seem very straightforward, but I can't seem to get it working. Here are my plugins... More on stackoverflow.com
🌐 stackoverflow.com
🌐
GitHub
github.com › mfussenegger › nvim-dap-python
GitHub - mfussenegger/nvim-dap-python: Mirror of https://codeberg.org/mfussenegger/nvim-dap-python · GitHub
An extension for nvim-dap providing default configurations for python and methods to debug individual test methods or classes. ... If you want to use the test runner functionality, it additionally requires a tree sitter parser for Python.
Starred by 697 users
Forked by 62 users
Languages   Lua 99.5% | Python 0.5%
🌐
Reddit
reddit.com › r/neovim › debugpy.nvim: command and api frontend to nvim-dap and debugpy (debugging python)
r/neovim on Reddit: debugpy.nvim: Command and API frontend to nvim-dap and Debugpy (debugging Python)
December 17, 2021 -

Hi there,

I use Python quite a lot and when I debug the code I want to be able to quickly specify what I want to debug and not have to manually create individual debugger configurations for each project. So I made a plugin that does it for you: debugpy.nvim (GitHub mirror). It provides a thin layer on top of nvim-dap.

I am a very big fan of the way nvim-dap is structured: it is basically just a Lua library with a reasonable minimum of UI, and it is really easy to build plugins on top of that. Debugpy.nvim provides a new command :Debugpy which allows you to specify a sub-command (currently module, program or attach) and arguments, and it will launch the debugger for you. Example:

" Debug a module with command-line arguments
Debugpy module main foo bar

" Attach to a running process
Debugpy attach 127.0.0.1 5678

Even if you don't like the command you can still use the API, which supports Lua and Vim script:

local debugpy = require 'debugpy'
local config = debugpy.configure('module', 'main', 'foo', 'bar')
debugpy.run(config)

You can define your own sub-commands and override the run function to alter how the debugger is started or to inject your own debugger settings. No setup function or other nonsense, just pure Lua and Vim script:

-- Your personal default settings
default = { justMyCode = false }

-- Implementation which injects your default settings
require('debugpy').run = function(config)
    local final = vim.tbl_extend('keep', config, default)
    require('dap').run(final)
end

I have been using this for a couple of months in my configuration, and now I have turned it into a proper plugin. I hope you enjoy it as well. And hey, it even comes with an actual manual! (sorry, I just had to make that jab)

🌐
Tamerlan
tamerlan.dev › a-guide-to-debugging-applications-in-neovim
A Guide to Debugging Code in Neovim - Tamerlan
January 21, 2025 - In this tutorial, I walk you through how to set up a debugging environment in Neovim using DAP for any programming language.
🌐
GitLab
gitlab.com › hiphish › debugpy.nvim
HiPhish / Debugpy.nvim · GitLab
October 2, 2022 - Command and configuration frontend for Debugpy and nvim-dap
Find elsewhere
🌐
Neovim Discourse
neovim.discourse.group › plugins
Debugpy + Nvim-DAP in a Docker container - help getting this to work? - Plugins - Neovim Discourse
May 12, 2021 - I think I am close, but it’s not really working yet. Here is my setup: GitHub - gwerbin/debugpy-in-docker at 0c0db5ff05d36b94ce1fb969e6b6a1295b26292c I perform these steps: Open the runtime/service.py file in Neovim for editing.
🌐
Zignar
zignar.net › 2025 › 03 › 02 › no-config-python-debugging-using-neovim
No-Config Python debugging using Neovim - zignar.net
python -m debugpy --listen localhost:5678 --wait-for-client myfile.py · This will create a service listening on port 5678 - waiting for some DAP client to connect before it executes myfile.py. For Neovim we’ve two popular DAP clients: ... In this post we’re going to use nvim-dap.
Top answer
1 of 2
2

I have just created video about how I solved problem with debugger for Python and make it working. It is simple and I show everything here https://www.youtube.com/watch?v=8urgm9LZI08

But basically, you need to add couple of plugins into init.lua, then call setup() function to set default values, then create few shortcuts for opening dapui and install also debugpy.

Here are data from my init.lua
 install plugins

 --DAP debugger 
  { 'mfussenegger/nvim-dap' },
  { 'theHamsta/nvim-dap-virtual-text' },
  { 'nvim-neotest/nvim-nio' },
  { 'rcarriga/nvim-dap-ui' },
  { 'mfussenegger/nvim-dap-python'},
  -- debugger end

 call setup functions

  require('dap-python').setup()
      require('dapui').setup()

install also debugpy

and shortcuts
vim.api.nvim_set_keymap("n", "<leader>db", ":DapToggleBreakpoint<CR>", {noremap=true})
vim.api.nvim_set_keymap("n", "<leader>dc", ":DapContinue<CR>", {noremap=true})
vim.api.nvim_set_keymap('n', '<leader>do', ':lua require("dapui").open()<CR>', { noremap = true, silent = true })

So your problem is cause you are missing that setup() call for require('dap-python').setup() require('dapui').setup()

Check this and I hope this will help you. Also all is on my video as well.

2 of 2
1
  • My Config DAP Javascript

      {
    "rcarriga/nvim-dap-ui",
    lazy = true,
    event = "BufRead",
    dependencies = {
      { "mfussenegger/nvim-dap", lazy = true },
      { "nvim-neotest/nvim-nio", lazy = true },
      {
        "mxsdev/nvim-dap-vscode-js",
        dependencies = {
          "microsoft/vscode-js-debug",
          version = "1.x",
          build = "npm i && npm run compile vsDebugServerBundle && mv dist out",
        },
        config = function()
          require("dap-vscode-js").setup({
            -- node_path = "node", -- Path of node executable. Defaults to $NODE_PATH, and then "node"
            debugger_path = vim.fn.stdpath("data") .. "/lazy/vscode-js-debug",
            -- debugger_cmd = { "extension" }, -- Command to use to launch the debug server. Takes precedence over `node_path` and `debugger_path`.
            adapters = {
              "chrome",
              "pwa-node",
              "pwa-chrome",
              "pwa-msedge",
              "node-terminal",
              "pwa-extensionHost",
              "node",
              "chrome",
            }, -- which adapters to register in nvim-dap
            -- log_file_path = "(stdpath cache)/dap_vscode_js.log" -- Path for file logging
            -- log_file_level = false -- Logging level for output to file. Set to false to disable file logging.
            -- log_console_level = vim.log.levels.ERROR -- Logging level for output to console. Set to false to disable console output.
          })
        end,
      },
    },
    config = function()
      require("user.dapui")
      local js_based_languages = { "typescript", "javascript", "typescriptreact" }
    
      for _, language in ipairs(js_based_languages) do
        require("dap").configurations[language] = {
          {
            type = "pwa-node",
            request = "launch",
            name = "Launch file",
            program = "${file}",
            cwd = "${workspaceFolder}",
          },
          {
            type = "pwa-node",
            request = "attach",
            name = "Attach",
            processId = require("dap.utils").pick_process,
            cwd = "${workspaceFolder}",
          },
          {
            type = "pwa-chrome",
            request = "launch",
            name = 'Start Chrome with "localhost"',
            url = "http://localhost:3000",
            webRoot = "${workspaceFolder}",
            userDataDir = "${workspaceFolder}/.vscode/vscode-chrome-debug-userdatadir",
          },
        }
      end
    end,
    keys = {
      { "<leader>d", "", desc = "  Debug" },
      { "<leader>dt", "<cmd>lua require'dap'.toggle_breakpoint()<cr>", desc = "Toggle Breakpoint" },
      { "<leader>db", "<cmd>lua require'dap'.step_back()<cr>", desc = "Step Back" },
      { "<leader>dc", "<cmd>lua require'dap'.continue()<cr>", desc = "Continue" },
      { "<leader>dC", "<cmd>lua require'dap'.run_to_cursor()<cr>", desc = "Run To Cursor" },
      { "<leader>dd", "<cmd>lua require'dap'.disconnect()<cr>", desc = "Disconnect" },
      { "<leader>dg", "<cmd>lua require'dap'.session()<cr>", desc = "Get Session" },
      { "<leader>di", "<cmd>lua require'dap'.step_into()<cr>", desc = "Step Into" },
      { "<leader>do", "<cmd>lua require'dap'.step_over()<cr>", desc = "Step Over" },
      { "<leader>du", "<cmd>lua require'dap'.step_out()<cr>", desc = "Step Out" },
      { "<leader>dp", "<cmd>lua require'dap'.pause()<cr>", desc = "Pause" },
      { "<leader>dr", "<cmd>lua require'dap'.repl.toggle()<cr>", desc = "Toggle Repl" },
      { "<leader>ds", "<cmd>lua require'dap'.continue()<cr>", desc = "Start" },
      { "<leader>dq", "<cmd>lua require'dap'.close()<cr>", desc = "Quit" },
      { "<leader>dU", "<cmd>lua require'dapui'.toggle({reset = true})<cr>", desc = "Toggle UI" },
    },},}
    
  • For Python use mason-nvim-dap

🌐
Better Programming
betterprogramming.pub › lunarvim-debugging-testing-python-code-fa84f804c469
LunarVim Debugging & Testing Python Code | by chris@machine | Better Programming
May 17, 2023 - LunarVim already includes two plugins for enabling dap and a rich visual experience using, nvim-dap, and nvim-dap-ui. So you just need to enable dap and setup your debug adapter. In this case, we’ll be setting up debugpy as our adapter.
🌐
AstroNvim
docs.astronvim.com › recipes › dap
Debugger Setup | AstroNvim Documentation
-- debugpy supports launching an application with a different interpreter then the one used to launch debugpy itself. -- The code below looks for a `venv` or `.venv` folder in the current directly and uses the python within. -- You could adapt this - to for example use the `VIRTUAL_ENV` environment variable. ... By default, AstroNvim sets up event listeners with nvim-dap to automatically open and close the nvim-dap-ui.
🌐
Medium
alpha2phi.medium.com › modern-neovim-debugging-and-testing-8deda1da1411
Modern Neovim— Debugging and Testing | by alpha2phi | Medium
January 29, 2023 - Configure a modern debugging and test-driven development environment with Neovim.
🌐
Nielscautaerts
nielscautaerts.xyz › debugging-python-in-neovim.html
Niels Cautaerts - Debugging python in neovim
April 24, 2021 - { "configurations": { "run": { "adapter": "debugpy", "default": true, "configuration": { "request": "launch", "type": "python", "cwd": "${workspaceRoot}", "stopOnEntry": true, "program": "${file}" }, "breakpoints": { "exception": { "raised": "N", "uncaught": "", "userUnhandled": "" } } } } }
🌐
Reddit
reddit.com › r/neovim › nvim-dap debugpy can't work in windows
r/neovim on Reddit: nvim-dap debugpy can't work in windows
January 18, 2024 -

I use lazyvim, after enable dap.core and lang.python in :LazyExtras, still can't debug python file.

after start debug, will pop a window, show following text

Content-Length: 137

{"seq": 1, "type": "event", "event": "output", "body": {"category": "telemetry", "output": "ptvsd", "data": {"packageVersion": "1.8.0"}}}Content-Length: 139

{"seq": 2, "type": "event", "event": "output", "body": {"category": "telemetry", "output": "debugpy", "data": {"packageVersion": "1.8.0"}}}

I search the same problem in github, others also have the problem, but no answers

https://github.com/LazyVim/LazyVim/issues/1284

https://github.com/mfussenegger/nvim-dap-python/issues/118

🌐
GitHub
github.com › mfussenegger › nvim-dap › wiki › Debug-Adapter-installation › 7f8c4267888bae0f7e6d177b569edc00de6c20c3
Debug Adapter installation · mfussenegger/nvim-dap Wiki · GitHub
mkdir .virtualenvs cd .virtualenvs python -m venv debugpy debugpy/bin/python -m pip install debugpy · You can then either use nvim-dap-python - it comes with adapter and configurations definitions - or define them manually as follows: local dap = require('dap') dap.adapters.python = function(cb, config) if config.request == 'attach' then ---@diagnostic disable-next-line: undefined-field local port = (config.connect or config).port ---@diagnostic disable-next-line: undefined-field local host = (config.connect or config).host or '127.0.0.1' cb({ type = 'server', port = assert(port, '`connect.port` is required for a python `attach` configuration'), host = host, options = { source_filetype = 'python', }, }) else cb({ type = 'executable', command = 'path/to/virtualenvs/debugpy/bin/python', args = { '-m', 'debugpy.adapter' }, options = { source_filetype = 'python', }, }) end end ·
Author   mfussenegger
🌐
Medium
alpha2phi.medium.com › neovim-debugging-application-70c525754064
Neovim — Debugging Application - alpha2phi
February 26, 2022 - Neovim — Debugging Application Debugging application written in Python, Golang, Rust, and Javascript/Typescript. Overview In a previous article on Neovim LSP and DAP, I set up DAP using nvim-dap …
🌐
Codeberg
codeberg.org › mfussenegger › nvim-dap-python
mfussenegger/nvim-dap-python: An extension for nvim-dap, providing default configurations for python and methods to debug individual test methods or classes. - Codeberg.org
An extension for nvim-dap providing default configurations for python and methods to debug individual test methods or classes. ... If you want to use the test runner functionality, it additionally requires a tree sitter parser for Python.