Run the Django backend with debugpy so you can attach a remote debugger from your IDE.
Note: With
--wait-for-client, the server will not start until a debugger is attached. Attach your IDE before expecting the app to respond.
name: conversations
services:
app-dev:
ports:
- "8071:8000" # App accessible at http://localhost:8071
- "5678:5678" # Debugger port
command: >
python -m debugpy --listen 0.0.0.0:5678 --wait-for-client
manage.py runserver 0.0.0.0:8000 --nothreading --noreloadmake runThe server will block until a debugger connects on port 5678.
Create .vscode/launch.json:
{
"version": "0.2.0",
"configurations": [
{
"name": "Python: Django Docker",
"type": "debugpy",
"request": "attach",
"connect": {
"host": "localhost",
"port": 5678
},
"pathMappings": [
{
"localRoot": "${workspaceFolder}/src/backend",
"remoteRoot": "/app"
}
]
}
]
}Then run the Python: Django Docker launch configuration (F5).
Note: debugpy support and Attach to DAP are available since PyCharm 2026.1.
- Go to Settings > Python > Debugger and set Debugger mode to
debugpy - Go to Run > Edit Configurations...
- Click + and select Attach to DAP
- Configure the following:
- Remote address:
localhost:5678 - Local project path:
<project root>/src/backend - Remote project path:
/app
- Remote address:
- Click OK, then start the debug configuration (Debug button or
Shift+F9)
F8- Step OverF7- Step IntoShift+F8- Step OutF9- Resume