user3115306
user3115306

Reputation:

How start server Django in the VM (Vagrant)

i want install Django in my VM created with PuPHPpet (Vagrant), then when i start the server with

python manage.py runserver 

My project is normally available in 127.0.0.1:8000 But i have unreachable web page, then i try

python manage.py runserver ipvm:8000 and others ports

I have always unreachable web page So, i have found in this forum

0.0.0.0:8000

And i have again unreachable web page, Why ? How can start my server in my VM ?

Upvotes: 3

Views: 3130

Answers (3)

Mohammed Elzanaty
Mohammed Elzanaty

Reputation: 393

  1. You have to forward the port from Vagrant to your local machine.

    config.vm.network :forwarded_port, host: 8001, guest: 8000

  2. Yo need to add IP to ALLOWED_HOST in your setting.py file

    0.0.0.0 to the ALLOWED_HOSTS in your settings.py

  3. Run Project

    python manage.py runserver 0.0.0.0:8000

Upvotes: 0

Sachin Shukla
Sachin Shukla

Reputation: 365

Run python manage.py runserver 0:8000. It worked for me

Upvotes: 0

mipadi
mipadi

Reputation: 410562

You have to forward the port from Vagrant to your local machine. You can add a line like this to your Vagrantfile:

config.vm.network :forwarded_port, host: 8001, guest: 8000

And then run this in the Vagrant VM:

python manage.py runserver 0.0.0.0:8000

And on your host machine, go to http://localhost:8001 to view the webpage.

Upvotes: 11

Related Questions