Skip to content

Instantly share code, notes, and snippets.

@giiska
Last active August 29, 2015 14:03
Show Gist options
  • Save giiska/063075d544bb363fb422 to your computer and use it in GitHub Desktop.
Save giiska/063075d544bb363fb422 to your computer and use it in GitHub Desktop.
set Django debug mode for site running inside virtualbox/vagrant

When visit Virtual Box site, the client ip is gateway of virtual machine, not your dev machine ip.

Check the true client ip

  • Add import pdb;pdb.set_trace() to any Django view, and open the view in chrome
  • Switch to termianl, request.META.get('REMOTE_ADDR', None) at the break point
  • The result is the true client ip address
DEBUG = True
# when config.vm.network is setted to 'forwarded_port'
INTERNAL_IPS = (127.0.0.1, 10.0.2.2)
DEBUG = True
# when config.vm.network is setted to 'private_network' with 'ip: "10.0.10.149"'
INTERNAL_IPS = (127.0.0.1, 10.0.10.1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment