D
D
Dmitry2021-03-13 14:42:30
Windows
Dmitry, 2021-03-13 14:42:30

How to forward a port from the built-in Ubuntu in Windows 10 to Windows itself?

I installed Ubuntu 18.04 on Windows 10, logged in to Ubuntu, went to the folder with the Flask project, installed all dependencies, started the server. It is available by default at 127.0.0.1:5000 .
But here's how to open a running web application in a browser on Windows?

Tried this:
ssh [email protected]<ip_ubuntu_server> -p 5000

But I get the answer:

ssh: connect to host <ip_ubuntu_server> port 5000: Connection refused


I have no experience in this and it is difficult to evaluate advice from the network.
Can someone tell me the recipe, or a link where this is explained.
Thank you.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry Belyaev, 2021-03-13
@trec

Firstly, modern wsl raises vlan and therefore localhost (127.0.0.1) will only be accessible from Ubuntu, but not from another wsl system and not from Windows.
There are many ways to find out the current IP address, including:
hostname -I
or
ip addr
Second, what does ssh have to do with a web server? Open in browser.
As a result:
- the application should listen not to 127.0.0.1 but to the vlan ip address, the easiest way is to listen to all addresses through 0.0.0.0
- you need to open it in the browser at the wsl ip address
You can prepare such a powershell script:

$wslIP = wsl -- hostname -I
$wslIP = $wslIP.Split(" ")[0]
OpenWith "http://${wslIP}:5000/"

B
BasiC2k, 2021-03-13
@BasiC2k

As usual, I do in such cases:
- Deploy a distribution (eg Ubuntu) in a virtual machine. For example - in VMWare;
- I set up everything that is necessary in the virtual machine, in the VMWare settings I set the "bridge" network connection. In this mode, the home router will see Ubuntu as just another physical machine. Hence Ubuntu will get its IP address on the home network. Here at this address you can access this virtual machine.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question