How to access localhost of linux subsystem from windows

18

4

I am using windows 10 and I have ubuntu 16.04 installed as linux subsystem. I am running a rails app on port 4567, which I want to access from windows.

I know an approach of using ip address, but ifconfig didn't work. (I tried running /sbin/ifconfig). This outputs a warning as, Warning: cannot open /proc/net/dev (No such file or directory). Limited output.

I searched in internet, came across this open issue. So is there any alternative feasible solution?

peeyushsrj

Posted 2016-10-05T20:28:39.613

Reputation: 183

>

  • The Ubuntu on Windows is based on 14.04. 2. You could simply use a VM. It's easier to setup, probably has a GUI (if you want one) and supports all the features you need.
  • < – GiantTree – 2016-10-05T20:41:31.320

    Well I upgraded it to 16.04.1. GUI not needed. V.M. makes system slow. – peeyushsrj – 2016-10-05T20:44:09.700

    Well, you could run Rails directly on Windows, removing Linux completely. – GiantTree – 2016-10-05T20:46:53.850

    For that windows needs to install ruby, devkit, rails etc. which makes system slow again. – peeyushsrj – 2016-10-05T20:54:23.577

    Answers

    29

    The answer to this is surprisingly simple which is why searching isn't giving you the right results.

    All that WSL does is provide a translation layer between the Linux apps and the windows kernel, very much like how Wine works on Linux. Because of this some core parts of the Ubuntu system are just not there, networking being one of them. WSL translates the Linux system calls into windows ones so the Ubuntu network data flows through the exact same TCP/IP stack as the windows data.

    In short this means to access the Linux localhost you just access the windows one, they are the same. localhost:4567 or 127.0.0.1:4567 will do what you want.

    As an aside I've been using rails on WSL, it seems to work perfectly except the swing and listen gems don't play well, I had to disable them.

    Owen Tourlamain

    Posted 2016-10-05T20:28:39.613

    Reputation: 543

    3

    It does work :) Installed Ubuntu, Nginx on it, started Nginx and now I can open http://localhost/ on windows :) Thanks

    – Lukas Liesis – 2018-07-24T20:39:23.397