Take the 2-minute tour ×

After starting my Sinatra application with both ruby app.rb and foreman start I am unable to access my application with localhost and the respective port on my host machine. I am also able to curl to the applications from within the shell of on guest machine, whereas on the host machine the curl request fails. As far as I know there shouldn't be a firewall in place on the guest machine because I'm using the Vagrant Ubuntu image.

My Vagrantfile is as follows:

Vagrant.configure('2') do |config|
  config.vm.box = 'precise32'
  config.vm.box_url = 'http://files.vagrantup.com/precise32.box'
  config.vm.network :forwarded_port, guest: 4567, host: 4567
share|improve this question
This might be because by default in development mode Sinatra only listens to localhost, not (I don’t know how Vagrant handles the forwarding and how the guest sees any requests). Does using set :bind, '' to your app make it available? –  matt Jan 21 at 12:51
add comment

1 Answer

up vote 3 down vote accepted

By default when running in development mode, Sinatra only listens to localhost, not to (this change was made due to security considerations).

To allow requests from any interface, either add set :bind, '' to your app file, or start your app with the -o option, e.g. ruby myapp.rb -o

You may be able to set this to the actual address assigned to the guest, but I don’t know if it will be worth it.

share|improve this answer
add comment

Your Answer


