[QUESTION] How to setup a remote debugger with vscode
See original GitHub issueDescription
Hi, I am trying to set up the vscode debugger with a remote container for FastAPI.
Here’s my launch.json
:
{
"version": "0.2.0",
"configurations": [
{
"name": "Python: Attacher",
"type": "python",
"request": "attach",
"port": 5678,
"host": "localhost",
"pathMappings": [
{
"localRoot": "${workspaceFolder}",
"remoteRoot": "/app"
}
]
}
]
}
In my docker-compose file, I export the ports 5678 (debugger) and 8000 (api) and the command is: uvicorn myapp.main:app --host 0.0.0.0 --port 8000 --reload
.
In main.py
, I’ve added the followling lines before uvicorn.run(...)
:
import ptvsd
ptvsd.enable_attach(address=('0.0.0.0', 5678), redirect_output=True)
When I try to run the debugger, I have this error happening in the vscode console (Help > Toggle Developer Tools):
ERR timeout after 500 ms: Error: timeout after 500 ms
at t.RawDebugSession.handleErrorResponse (file:///Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:2798:1003)
at file:///Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:2798:434
at async t.RawDebugSession.shutdown (file:///Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:2796:536)
at async file:///Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:5182:409
In my process I checked a lot of resources to no avail such as:
Issue Analytics
- State:
- Created 4 years ago
- Reactions:3
- Comments:11 (5 by maintainers)
Top Results From Across the Web
Visual Studio Code Remote Development
Visual Studio Code Remote Development allows you to use a container, remote machine, or the Windows Subsystem for Linux (WSL) as a full-featured...
Read more >SSH, Remote and Live Debugging in VS Code with Lightrun
VS Code offers a variety of tools for debugging difficult scenarios - in local environments, in far-away remote servers and beyond the ...
Read more >How do attach to a remote Java debugger using Visual Studio ...
Create a Debug Configuration like below and press F5 to debug : "version": "0.2.0", "configurations": [ { "type": "java", "name": "Debug ...
Read more >Debugging - vscode-docs
To debug your app in VS Code, you'll first need to set up your launch configuration file - launch.json . Click on the...
Read more >Azure functions remote debugging in Visual Studio Code
Microsoft Q&A is the best place to get answers to all your technical questions on Microsoft products and services. Community. Forum.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@Kludex I used your solution as a template and I can debug and hit breakpoints, thank you.
Launch.json
docker-compose.debug.yml
Command to run backend in debug mode
docker-compose -f docker-compose.debug.yml up
You’re welcome. 😗