Enabling WSL2 Support in Firewall Settings

Unlike WSL1 that shares the same IP addresses (including localhost) between Windows and Linux sides, WSL2 distros run inside separate lightweight virtual machines and cannot directly communicate to the Windows host unless explicitly enabled in firewall settings.

VisualGDB relies on the ability to communicate between the WSL target and Windows, hence in order to use WSL2 targets with VisualGDB, you would need to enable TCP/IP connections from WSL2 hosts. The easiest way to configure it is shown below:

  1. Locate PowerShell in the Start menu, right-click on it and select “Run as Administrator”.
  2. In the Administrative PowerShell Prompt run the following command:

  3. Now you can select WSL2 targets in VisualGDB dialogs and they will work out-of-the-box, just like WSL1 targets.