Quantcast
Channel: Makai's Blog
Viewing all articles
Browse latest Browse all 40

Accessing a Django Server on a VirtualBox Ubuntu Instance

$
0
0

I do the majority of my development work on virtualized Ubuntu instances to closely mimic my production deployment environment. Today I needed to access a Django server running on the VirtualBox instance from my host operating system (Windows 7).

I was simply using the built-in Django server (manage.py runserver) running on a high-level port instead of deploying to Apache or gunicorn. To do a pass through with this set up, use the following 3 steps:

  1. Change the VirtualBox network adapter (Devices -> Network Adapter -> Adapter 1) to “Bridged Adapter” instead of NAT.
  2. Inside the virtualized OS, run ifconfig -a to see the new inet addr (mine happened to be http://10.38.1.119.
  3. Use the python manage.py runserver 10.38.1.119:8000 command (with your new IP address and the port above 1024 you want to run on) to run the Django server and allow external access

Now you should be able to access the Django server from your host OS through the browser at 10.38.1.119:8000 (again, replace with your specific IP and port number).

References:

[1] How to connect from Windows 7 to localhost on Ubuntu VirtualBox

[2] VirtualBox accessing ubuntu localhost thread


Viewing all articles
Browse latest Browse all 40

Trending Articles