How to setup vagrant with ubuntu as development server on windows 10?

I installed vagrant on my windows 10 with ubuntu. I want to make ubuntu as my development environment.

In my Vagrantfile I uncomment forwarded_port and edit as follows:

config.vm.network "forwarded_port", guest: 8080, host: 8080, host_ip: "127.0.0.1" config.vm.network "forwarded_port", guest: 5000, host: 5000, host_ip: "127.0.0.1"

Here, I want to access in my browser under the windows if I run pyhon on ubuntu.

In, ubuntu I created a simple "hello world" python script using flask framework. I called it main.py. When i run the script with command 'python main.py', it says:

"Running on http://127.0.0.1:5000/"...

So, back in my windows, I tried to access the link to my browser. Unfortunately, the "hello world" did not show up.

Is there anything I need to do in the setup? Please help. Thank you.

Upvotes: 1

Views: 83

Answers (1)

Dave W. Smith
Dave W. Smith

Reputation: 24966

Inside the VM, 127.0.0.1 is local, and the world outside the VM isn't. Change your run() to include host='0.0.0.0', or switch to using the flask command, and pass --host=0.0.0.0.

Upvotes: 1

Related Questions