2021-03-26

Docker and Python debugging in VS Code error: timed out waiting for launcher to connect

Scenario: you have a Linux machine and you're creating a Dockerized Python app. You fire up Visual Studio Code, follow the official instructions, and eagerly hit F5 to test your app.

But nothing happens, except an error dialog after about 15 seconds:


This may be your firewall blocking connections on the docker network interface.

To confirm this, turn off your firewall, launch a debug process in VS Code, and see if the debug session starts. Repeat with the firewall on. If that fails, it's time to add rules allowing traffic for the docker interface.

First, find the subnet for your docker interface:



In this instance, you want traffic allowed through docker0 over its IP range, which in my case is 172.17.0.0/16. Yours may be different.

In a terminal, add those rules:

sudo ufw allow out on docker0 from 172.17.0.0/16
sudo ufw allow in on docker0 from 172.17.0.0/16

Reload your firewall config, and your debugging should start working.

sudo ufw reload