I'm trying to let WSL use a localhost proxy(actually its Fiddler) on my windows, but I can't see any connection like that, and downloads usually fail, how do I fix that?

I know that I can connect to Linux localhost from the windows one, but how can I reverse this?

WSL is Ubuntu 18.04

  • add to your question: What OS. a OS tag.
    – somebadhat
    Mar 24 '20 at 4:05

I am not sure if the following will work with applications that are bound to just localhost, but this worked for Fiddler and WSL2:

  1. Set the Fiddler option "Allow remote computers to connect" and restart Fiddler Fiddler options: allow remote computers to connect

  2. Grab your WSL network connection info (on my machine, the adapter is called vEthernet (WSL)) WSL network connection details

  3. Use that address, e.g. where you would normally use localhost curl -I output in WSL2

  • 1
    For me to make this working windows firewall settings for port 8888 needs to be adjusted, however I cannot find any quick solution for that so I went into dirty path of disabling whole firewall for WSL vEthernet by PS command Set-NetFirewallProfile -DisabledInterfaceAliases "vEthernet (WSL)". There are multiple issues on WSL github for those problems e.g github.com/microsoft/WSL/issues/4585
    – grexlort
    Jul 5 '20 at 12:54

You should run the following command in a powershell run as administrator:

New-NetFirewallRule -DisplayName "WSL" -Direction Inbound  -InterfaceAlias "vEthernet (WSL)"  -Action Allow

This command comes from this WSL2 ticket. Any firewall rule related to WSL IP address won't be effective because with WSL2 IP changes every time.

  • 1
    I used your rule and export hostip=$(cat /etc/resolv.conf | grep nameserver | awk '{ print $2 }') from here and I'm all set, thanks!
    – headsvk
    Mar 26 at 12:10

WSL 2 requires some extra work as compared to WSL 1.

  1. Allow the required port(s) through the firewall.

    1.1 Launch Windows Defender Firewall with Advanced Security

    1.2 On the left pane select Incoming Rules.

    1.3 On the right pane click on New Rule.

    1.4 For the rule type select Port. Next.

    1.5 Select TCP and Specific local ports. Insert the port, a comma-separated list of ports or a port range. Next.

    1.6 Select Allow connection. Next.

    1.7 Check only the Public profile. Next.

    1.8 Enter a name for the rule. e.g. WSL. Done.

  2. Find out the IP Address of WSL from within it:

grep -m 1 nameserver /etc/resolv.conf | awk '{print $2}'

This is the IPv4 Address of the Network Interface vEthernet (WSL).

  1. Test the connection to the Windows host using curl or telnet:

    3.1 curl ip.from.step.2:port

I have used this procedure to connect to an Oracle server and an X server running on Windows.

Update: Since the IP Address of WSL will change every time Windows is restarted, it is convenient to automatically fetch it and update the hosts file.


  1. execute cat /etc/hosts to find out the name of the Windows host.

  2. Add the following code to ~/.profile:

    IP_HOST=$(grep -m 1 $HOST /etc/hosts)
    OLD_IP=$(echo "$IP_HOST" | awk '{print $1}')
    NEW_IP=$(grep -m 1 nameserver /etc/resolv.conf | awk '{print $2}')
    if [ "$NEW_IP" != "$OLD_IP" ]; then
       echo "Updating IP Address-hostname mapping"
       sudo sed -i "s|$IP_HOST|$NEW_IP\t$HOST|" /etc/hosts
       echo "$HOST has the IP Address $NEW_IP"
  • 1
    It works, however it need to be done again and again and makes the db public...
    – Kiruahxh
    Jan 26 at 16:50
  • 1
    @Kiruahxh I just added a script to automatically update the IP-Hostname mapping. In the case of Oracle DB, instead of opening the port in the Firewall you can add a rule to allow connections to C:\oraclexe\app\oracle\product\11.2.0\server\BIN\tnslsnr.exe.
    – Marduk
    Jan 27 at 8:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.