Django to the world

Django to the world

When your shiny new Django site is invisible to other machines …

Summary

The default setting in Django means your development server is invisible to other machines

Todays Learning Point

When a developer creates a nice new Django site and uses the django-admin.py script :

django-admin.py runserver

to start the development server. By default the development server is responding to requests made on port 8000 on IP address 127.0.0.1 (or the synonym ‘localhost’). As such you’re not going to be able to see that Django site from any other machine.

In most cases this is just what’s needed. The development server is intended for use by the developer only. However there may be circumstances where you want another developer to see your work – or as happened to me today where you are developing on a virtual machine running within your development machine.

If that’s the case there’s a way around it

Specify IP on Server Launch

You can issue a slightly different command when starting the development server

python manage.py runserver 0.0.0.0:8000

The above command will listen on port 8000 of all public IP addresses of the hosting machine and that in turn will mean other machines can access the Django site served through your development server.

Leave a Reply

Your email address will not be published. Required fields are marked *