7

I simply want to connect from my WSL2 Ubuntu installation to my host windows on port 8529.

What I tried:

This question has been ask quite a view times, but none of the usual answers worked for me.

3
  • If disabling the public firewall on the host helped, why don't you add a firewall rule on the host to allow this one connection? And why the public and not the private firewall?
    – harrymc
    Commented Apr 1, 2022 at 10:15
  • I tried to add a rule, but it just didn't work (the last 2 points on my list). I tried to disable the private firewall an nothing happened only when I disabled the public firewall. Commented Apr 4, 2022 at 8:00
  • I had the same issue, port- or even interface-based rules such as New-NetFirewallRule -DisplayName "WSL_Inbound" -Direction Inbound -InterfaceAlias "vEthernet (WSL)" -Action Allow just don't work.
    – DoNuT
    Commented Oct 6, 2022 at 12:28

3 Answers 3

11

You can disable the firewall only for the vEthernet (WSL) interface. This way you will allow connections from WSL while still having the firewall protect your computer from external threats.

  • Go to Firewall Settings and click on Advanced Settings
  • Click Windows Defender Firewall Properties
  • Select Public Profile tab
  • Click Customize Protected network connections enter image description here
  • Unclick vEthernet (WSL)
8
  • 2
    It works but I wonder why the firewall rule 'New-NetFirewallRule -DisplayName "WSL" -Direction Inbound -InterfaceAlias "vEthernet (WSL)" -Action Allow' does not work
    – HamedH
    Commented Aug 7, 2022 at 16:32
  • This works and is still better than totally disabling the firewall but in company environments with managed workstations (for example Microsoft Intune) this might give administrators red lights flashing because of noncompliant firewall settings. No problem if your admin doesn't care or can be bribed but I also didn't get any working rules set up for the WSL adapter.
    – DoNuT
    Commented Oct 6, 2022 at 12:31
  • 2
    This can be scripted (PowerShell): Set-NetFirewallProfile -Profile Public -DisabledInterfaceAliases "vEthernet (WSL)" (disables for Public profile only)
    – sudoqux
    Commented Jan 31, 2023 at 12:27
  • @sudoqux I don't have access to change it in the UI, but I could run the PS command. However, after running it for all three of public, private, domain, I still cannot reach :8026 on WSL.
    – mbomb007
    Commented Mar 3, 2023 at 17:40
  • @mbomb007 Try verifying that it was disabled, by running Get-NetFirewallProfile | Select Name,DisabledInterfaceAliases. If vEthernet (WSL) is listed under DisabledInterfaceAliases, i don't think it is a firewall issue.
    – sudoqux
    Commented Mar 8, 2023 at 6:48
1

Well, in my case I use CentOS 7 WSL App. I didn't have success manage on Norton 360. So in In Rules (I don't how is on English SO) I've added do CentOS 7 app. And worked for me.

CentOS 7:
CentOS 7

And I have success to ping to google.com

0

Because Windows randomly turns on the firewall without your acknowledge, enforce a cron job to disable it might be the only compromised solution. Partially from @sudoqux

# run as Admin and in windows powershell
$option = New-ScheduledJobOption -RunElevated -RequireNetwork
$atLogin = New-JobTrigger -AtLogOn -User *
$atInterval = New-JobTrigger -Once -RepeatIndefinitely -RepetitionInterval "00:10:00" -At "0am"
Register-ScheduledJob -Name "F wsl firewall" -ScheduledJobOption $option -Trigger $atLogin, $atInterval -ScriptBlock {
    Set-NetFirewallProfile -Profile Public -DisabledInterfaceAliases "vEthernet (WSL)";
}

(I know basically nothing about windows powershell, so please let me know if I'm wrong.)

Also don't forget to enable inbound rules on the "Windows" host side.

(Anyway, I don't see any meaningful reasons to reject all of the outgoing connections on WSL to host, considering the host already had its inbound rules.)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .