Blog2013 ≫ Ruby / Sinatra app only available to localhost

Revisited some work last night, a little api into my home automation work so I can expose it to the web and get started on a phone app. All was working OK previously, thought nothing had changed but suddenly my work was not accessible over the web, only over localhost... This is a common beginners issue with Sinatra1, if you just make a simple app like

#!/usr/bin/ruby
require 'sinatra'
get '/' do
  'Hello!'
end

That will show you a web page saying "Hello!" when you hit the root, ie /. With no other changes this will respond on port 4567, and importantly only be available to localhost no other machines. I knew this, so had this code:

#!/usr/bin/ruby
require 'sinatra'
configure do
  set :bind, '0.0.0.0'
end
get '/' do
  'Hello!'
end

to mean "respond on all ip addresses". But it had stopped working. I tried equivalent options, removing that configure block and trying launching the app with

[api](/wiki/#api).php -o 0.0.0.0

and then

[api](/wiki/#api).php -o 192.168.1.73 # the actual ip on my network

and then also

[api](/wiki/#api).php -e production

which puts it in production mode (where you'd want to be visible externally). But still no joy.

It just came to me this morning that as I'm working from home I have Junos Pulse enabled on my machine to get me onto the work network, and that is what is fouling it up! Haven't tested it yet as I have to work, but I bet that is it...

⬅️ :: ➡️

Paul Clarke's blog - I live in A small town, Kent. Wed + father to two, I am a full stack web developr, + I do js / nodejs, some ruby, other languages ect ect. I like pubbing, running, eating, home-automation and other diy jiggery-pokery, history, genealogy, Television, squirrels, pirates, lego, + TIME TRAVEL.