Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Win7 Host and Ubuntu Server on Virtualbox guest port forwarding issue

I'm trying to set up what I believe to be a rather common Django development server configuration, but I'm having issues with the port-forwarding between the guest OS and the host OS.

I'm running:

  • Win7 Host
  • VirtualBox 4.1.2
  • Ubuntu Server 11.04 Guest.

I'm connecting to the VirtualBox with NAT and using the built-in VirtualBox Port Forwarding functionality (from the guest's Settings -> Network -> Port Forwarding menu) such that my .vbox XML contains the following section:

<NAT>
        <DNS pass-domain="true" use-proxy="false" use-host-resolver="false"/>
        <Alias logging="false" proxy-only="false" use-same-ports="false"/>
        <Forwarding name="guestdjango" proto="1" hostip="127.0.0.2" hostport="9080" guestport="8080"/>
        <Forwarding name="guesthttp" proto="1" hostip="127.0.0.2" hostport="8080" guestport="80"/>
        <Forwarding name="guestssh" proto="1" hostip="127.0.0.2" hostport="2222" guestport="22"/>
</NAT>

From the host, I can SSH/SFTP into the guest on port 2222, I can see the nginx "Welcome to nginx!" at 127.0.0.2:8080.

After verifying these, I set up Django and run the Django runsever:

python manage.py runserver 127.0.0.1:8080

With Lynx from the guest, I get the "Congratulations" Django page at 127.0.0.1:8080.

However, when I navigate to 127.0.0.2:9080 from the host, I get "The connection was reset."

like image 699
urbushey Avatar asked Nov 30 '22 07:11

urbushey


1 Answers

I'm not completely sure how it works with port forwarding, but normally to expose the runserver to the external network you need to bind it to something other than localhost - ie run python manage.py runserver 0.0.0.0:8080. See if that works.

like image 136
Daniel Roseman Avatar answered Dec 06 '22 11:12

Daniel Roseman