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:
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."
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With