nutship
nutship

Reputation: 4934

Running django on 0.0.0.0:8000

I am using vagrant along with Virtualbox, so I can't runserver on the default port and address or it won't work.

Django says:

(...) to listen on all public IPs (useful if you want to show off your work on 
other computers), use:

python manage.py runserver 0.0.0.0:8000

Then I tried to access the server via http://127.0.0.1:8888/ but it says Unable to connect. Any guess how to run the server correctly?

I have followed the gettingstartedwithdjango vidoes and this http://127.0.0.1:8888/ worked for the author.

Upvotes: 5

Views: 16288

Answers (2)

douggard
douggard

Reputation: 722

For people who are just looking where to configure the IP, it is run like so (as seen in the OP) -

python manage.py runserver 0.0.0.0:8000

If you are accessing it over your local network you will also need to update settings.py with the IP of your host, as well as specifying localhost. Your local IP can be gotten on Windows by running ipconfig in the command prompt, or ip addr show in the terminal on Ubuntu.

ALLOWED_HOSTS = ['192.168.1.XXX', 'localhost']

Upvotes: 6

scriptmonster
scriptmonster

Reputation: 2771

You have to run with root privileges. If you run with sudoyou will succeed.

UPDATE 1

The previous information is irrelevant with the topic. In vagrant you have to forward your port to a local port. Please have a look at this.

UPDATE 2

This page explained how to install and configure django in a vagrant box.

Upvotes: 2

Related Questions