Search code examples
rubynetwork-programmingsinatrapumaforeman

Sinatra APP running with foreman on raspberry not reachable in Home-Network


I have a question. Maybe this is easy and i just dont come behind it. I wrote a little Sinatra (ruby) WebApp. It is running with a puma server and is started with foreman. I now started it on my Raspberry (Raspian stretch). This is working.

14:28:45 web.1  | started with pid 10847
14:28:52 web.1  | Puma starting in single mode...
14:28:52 web.1  | * Version 3.12.0 (ruby 2.5.1-p57), codename: Llamas in Pajamas
14:28:52 web.1  | * Min threads: 0, max threads: 16
14:28:52 web.1  | * Environment: development
14:28:52 web.1  | * Listening on tcp://localhost:10001
14:28:52 web.1  | Use Ctrl-C to stop

I can access it locally on my raspberry.

curl localhost:10001

this is working.

But I also want to reach it with my PC (Home network). And this is not working. I can ping the raspberry successfully.

ping 192.XXX.XXX.XX

but when i ping the port it is running on, it is not working (also try that with my browser). I have a fritzbox.

ping 192.XXX.XXX.XX:10001

Procfile:

web: bundle exec rackup -p 10001 -s puma

I am not sure what i am doing wrong :-( .


Solution

  • By default rackup binds to localhost. You have to tell it to listen on 0.0.0.0

    rackup -p 10001 -o 0.0.0.0

    or

    rackup -p 10001 --host 0.0.0.0

    Related source here: https://github.com/rack/rack/blob/master/lib/rack/server.rb#L56