Skip to content

WSL2 - Access running server from other computer within same network #4523

Closed

Description

I have dnsmasq running on my router which points all *.local domains to my Windows 10 machine, which has a fixed DHCP-address like 192.168.1.100.

Previously, when I used Docker for Windows with WSL1 (exposed deamon), I could access a running nginx-server from any device within my wireless network with http://project1.local, etc...

In WSL2 this does not work anymore, even that I've modifed my Windows 10 hosts file to point project1.local to the eth0 address, which is 172.25.21.243 of the WSL2 instance.

So my Windows 10 hosts file looks like this:

172.25.21.243 project1.local project2.local

I can't even access the server via http://192.168.1.100

Any suggestions how to make a server which is running inside WSL2 accessible from any other device on the same network as the Windows 10 machine?

Activity

  1. archilkarchava commented on Sep 22, 2019

    @archilkarchava

    #4150 (comment)
    You can use this script to forward ports and then you can just use your 192.168.1.100-like address.

  2. ad-on-is commented on Sep 23, 2019

    @ad-on-is
    Author

    Archil Karchava (@archilkarchava) I thought this workaround was obsolete since they added "localhost" to WSL 2 in one of the latest releases

  3. archilkarchava commented on Sep 23, 2019

    @archilkarchava

    Adis Durakovic (@ad-on-is) It's not obsolete, since you still have to forward the ports to expose them to your local network.

  4. therealkenc commented on Sep 28, 2019

    @therealkenc

    Can use #4150 as the LZ. The localhost feature will help on 127.0.0.1 but does not resolve to non-localhost IP addresses even if you are on the same physical machine. Short story, there is no IP forwarding.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions