Port forwarding with VirtualBox

portport-forwardingvirtualbox

I have a virtualbox VM running ubuntu.

The Ubuntu guest is running a web server which listens on port 3000 (http://127.0.0.1:3000)

The host machine is windows vista.

I have configured port forwarding using VBoxManage.

If I query the config using VboxManage getextradata "MyMachine", I get

Key: GUI/AutoresizeGuest, Value: on
Key: GUI/Fullscreen, Value: off Key:
GUI/LastCloseAction, Value: shutdown
Key: GUI/LastWindowPostion, Value:
9,34,640,529,max Key:
GUI/MiniToolBarAlignment, Value:
bottom Key: GUI/MiniToolBarAutoHide,
Value: off Key:
GUI/SaveMountedAtRuntime, Value: yes
Key: GUI/Seamless, Value: off Key:
GUI/ShowMiniToolBar, Value: yes Key:
VBoxInternal/Devices/pcnet/0/LUN#0/Config/guesthttp/GuestPort,
Value: 3000 Key:
VBoxInternal/Devices/pcnet/0/LUN#0/Config/guesthttp/HostPort,
Value: 3000 Key:
VBoxInternal/Devices/pcnet/0/LUN#0/Config/guesthttp/Protocol,
Value: TCP

This looks like it should work…

However when I try to access the web server from the host machine (windows box) I dont get a response.

I ran a netstat on the windows box and nothing appears to be listening on port 3000 which explains why forwrding isnt working.

Note that I have already tested with my firewall switched off…

The version of VirtualBox I am using is 3.1.4

Any ideas?

Best Answer

I assume that this question is related to your previous question about VirtualBox.

Have your configured your Ubuntu web server to listen on the ethernet network interface (probably eth0) with the IP address of 10.0.2.15? If not, configure your web server to listen on the ethernet network interface. My guess is that your web server is only configured to listen on the loopback interface 127.0.0.1 — 127.0.0.1 is only accessible within your Ubuntu VM. ie it is not accessible from your Windows host.

As others mentioned in your previous question: configure VirtualBox to use bridged networking mode so that your VM becomes just another machine on your network. Bridged networking mode ends up being simpler and you won't have to bother with VirtualBox port forwarding. :-)