how run pybottle in vagrant
Question: I have this Vagrant file

    
    
    # encoding: utf-8
    # -*- mode: ruby -*-
    # vi: set ft=ruby :
    
    Vagrant.configure("2") do |config|
        config.vm.box = "ubuntu/trusty64"
        config.ssh.forward_agent = true
        config.vm.boot_timeout = 300
        config.vm.network "private_network", ip: "192.168.30.20"
        config.vm.network :forwarded_port, guest: 8080, host: 8080
        config.vm.synced_folder "", "/vagrant", type: "nfs"
    
        config.vm.provision "shell", inline: <<-SHELL
          apt-get install python-pip build-essential python-dev -y
          pip install bottle
        SHELL
    
        config.vm.provider "virtualbox" do |v|
            v.name = "M101P"
            v.memory = 524
        end
    
        config.vm.define :M101P do |t|
            config.vm.hostname = "M101P"
        end
    end
    

This is a vagrant machine for learn pybottle...

and i have this code: (hello.py)

    
    
    from bottle import route, run, template
    
    @route('/hello/<name>')
    def index(name):
        return template('<b>Hello {{name}}</b>!', name=name)
    
    run(host='localhost', port=8080, debug=True)
    

But, when i tray to access to the server, after make

> python hello.py
    
    
    python hello_bottle.py
    Bottle v0.12.9 server starting up (using WSGIRefServer())...
    Listening on http://localhost:8080/
    Hit Ctrl-C to quit.
    

the server its running, but if y tray to access...

    
    
    curl 192.168.30.20:8080/hello/world
    curl: (7) Failed to connect to 192.168.30.20 port 8080: Connection refused
    

what i may be doing wrong?


Answer: The server just binds to localhost which is 127.0.0.1; if You want to access
the server via the server ip You have to change

    
    
    run(host='localhost', port=8080, debug=True)
    

to

    
    
    run(host='0.0.0.0', port=8080, debug=True)
    

