python - Accessing ubuntu virtual machine host from windows browser -


i have virtualbox ubuntu machine running hellow world flask app.

i tried having app display on 127.0.0.1:5000 , 0.0.0.0:5000

but both when try load on windows browser don't resolve.

when run ifconfig in ubuntu virtual machine 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           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           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 windows machine run ip config 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 reason when go 192.168.56.1 in windows browswer loads white page. if go 192.168.56.1:5000 says can not connect.

in virtual box have "attached to: nat" , port forwarding rules show

ssh tcp 127.0.0.1 host port 2222 guest ip empty , guest port 22

my flask app shows

 * running on http://0.0.0.0:5000/ (press ctrl+c quit)  * restarting stat 

also tried

 * running on http://127.0.0.1:5000/ (press ctrl+c quit)  * restarting stat 

answer question can find in virtualbox documentation: https://www.virtualbox.org/manual/ch06.html 6.3.1. configuring port forwarding nat

you can forward port 5000 guest os (ubuntu) host one. on host side can use same port number (if it's not occupied else, sure)


Comments