André Luiz
André Luiz

Reputation: 7292

How to access django website within a virtualbox/vagrant server?

I'm working in a project that uses vagrant to create environments, which is new to me (I'm loving it). In my vagrantfile i have these forwards:

dev.vm.network "forwarded_port", guest: 80, host: 8000
dev.vm.network "forwarded_port", guest: 8080, host: 8080
dev.vm.network "forwarded_port", guest: 8000, host: 8001
dev.vm.network "forwarded_port", guest: 3306, host: 3307
dev.vm.network "forwarded_port", guest: 6379, host: 6380
dev.vm.network "forwarded_port", guest: 9200, host: 9201
dev.vm.network "forwarded_port", guest: 5555, host: 5556

And then I start the django dev server using python manage.py runserver. It looks like the server is running OK, I get this message:

Django version 1.8.7, using settings 'config.settings.development'
Starting development server at http://127.0.0.1:8000/

And when I try to access the url above I receive a "Welcome to nginx!" page. Which is not the django project homepage.

I'm a bit confused. The forward seems OK and I don't understand yet why I'm getting the nginx page.

Thanks in advance for any help

Upvotes: 2

Views: 1034

Answers (1)

FlipperPA
FlipperPA

Reputation: 14311

You're forwarding port 80 on the Vagrant VM to port 8000 on your host machine, so you will see nginx at the URL with port 8000.

Port 8000 is forwarded to 8001 on your host machine, so you need to visit:

http://127.0.0.1:8001/

Give that URL a try in your browser.

Update: try this command:

python manage.py runserver 0.0.0.0:8000

Then try the URL above, or:

http://localhost:8001/

Good luck!

Upvotes: 3

Related Questions