I have a virtualbox ubuntu machine running a hellow world flask app.
I tried having the app display on 127.0.0.1:5000 and 0.0.0.0:5000
But both when I try to load up on my windows browser don't resolve.
When I run ifconfig in ubuntu virtual machine I get this:
ifconfig -a
eth0 Link encap:Ethernet HWaddr 08:00:27:6f:2c:93
inet addr:10.0.2.15 Bcast:10.0.2.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fe6f:2c93/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:657 errors:0 dropped:0 overruns:0 frame:0
TX packets:559 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:61322 (61.3 KB) TX bytes:73104 (73.1 KB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
And when on my windows machine I run ip config I get this:
ipconfig
Windows IP Configuration
Ethernet adapter Local Area Connection:
Media State . . . . . . . . . . . : Media disconnected
Connection-specific DNS Suffix . :
Wireless LAN adapter Local Area Connection* 4:
Media State . . . . . . . . . . . : Media disconnected
Connection-specific DNS Suffix . :
Ethernet adapter Bluetooth Network Connection:
Media State . . . . . . . . . . . : Media disconnected
Connection-specific DNS Suffix . :
Wireless LAN adapter Local Area Connection* 2:
Media State . . . . . . . . . . . : Media disconnected
Connection-specific DNS Suffix . :
Wireless LAN adapter Wi-Fi:
Connection-specific DNS Suffix . :
Link-local IPv6 Address . . . . . : fe80::2140:c809:4677:98bc%3
IPv4 Address. . . . . . . . . . . : 10.32.16.32
Subnet Mask . . . . . . . . . . . : 255.0.0.0
Default Gateway . . . . . . . . . : 10.128.128.128
Ethernet adapter VirtualBox Host-Only Network:
Connection-specific DNS Suffix . :
Link-local IPv6 Address . . . . . : fe80::3568:3fc7:1697:a475%10
IPv4 Address. . . . . . . . . . . : 192.168.56.1
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . :
Tunnel adapter isatap.{2543650F-5CEA-40B8-B085-A54A628D3DCE}:
Media State . . . . . . . . . . . : Media disconnected
Connection-specific DNS Suffix . :
Tunnel adapter isatap.{8A555006-09A6-4A20-986D-F59F5741DCCE}:
Media State . . . . . . . . . . . : Media disconnected
Connection-specific DNS Suffix . :
But for some reason when I go to 192.168.56.1 in my windows browswer it loads a white page. If I go to 192.168.56.1:5000 it says it can not connect.
In my virtual box I have it "attached to: NAT" and port forwarding rules show
ssh TCP 127.0.0.1 host port 2222 guest ip is empty and guest port is 22
My flask app shows
* Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)
* Restarting with stat
Also tried with
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
* Restarting with stat
answer to your question you can find in VirtualBox documentation: https://www.virtualbox.org/manual/ch06.html 6.3.1. Configuring port forwarding with NAT
You can just forward port 5000 from guest OS (Ubuntu) to host one. On the host side you can use the same port number (if it's not occupied by someone else, sure)
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments