[Django]-Debugging dockerized Django in VS Code results in error "Timed out waiting for launcher to connect"

1👍

My issue were missing packages. Docker usually works fine, I haven’t had any issues before at all.

I originally installed docker like described in the official documentation:
https://docs.docker.com/engine/install/ubuntu/

But after I tried installing the docker.io package, debugging worked fine in VS Code:

sudo apt install docker.io
👤Linus

2👍

The idea of debugging in vs code is to:

  • use debugpy to launch your code with a port, say 5678
  • in vscode to ‘Remote Attach’ to that process.

I may be wrong but what i can see from your code, you didn’t attach to your process.

I wrote the way I did here, I use docker-compose and docker. My way is different with yours but you will get the idea…:)

0👍

There’s no errors compared to the vscode tutorial in your project. Cause the error is timeout waiting for luncher to connect, try restart docker service and reload your window in vscode.

0👍

Here is a clue and a workaround:

The instructions I followed had me open VS code inside my ubuntu WLS2 instance. Note: my app is just a generic python app, not django.

VS code on WSL

If I click this and change it to open as a windows folder, then fun debug, everything suddenly works for me. (It spins up the docker and connects to it with debug, does breakpoints etc.)

VS code native windows

I think what is happening for me is that "sometimes" docker is starting the container/app on its own WSL instance and my ubuntu instance cannot route to it for the debug.

enter image description here

I say sometimes, because sometimes it works. I think it might be related to which application (docker, ubuntu, vscode) I start first when I boot my machine.
I’ve messed with the docker, resources, WSL integration settings, the windows firewall, and restarted various things.

I’m sure a proper fix is not that complicated, however running VS code in native windows is enough of a fix for me. I don’t see why the added complexity of starting the VS code session inside WSL is actually necessary.

Leave a comment