I have rails application. If I start it with rails s
(port 3000), it works perfectly both on my machine and every device on my local network via the ip address (192.168.0.3 in my case).
I have sinatra application. If I start it with ruby app.rb
(port 4567), it works perfectly on my machine, but it it is not accessible from other devices on my local network.
Both application use Thin as an app server.
Is it something related to how sinatra works?
Let me add some further info to Ivan's answer. Sinatra's README on command line says:
Per the document the default HOST is 0.0.0.0, but I still have to specify a "-o 0.0.0.0" just like Ivan said. Otherwise the server cannot be accessed from outside the server machine. How strange!
Try
ruby app.rb -o 0.0.0.0
orruby app.rb -e production
. Either should work.Just want to add to Ivan's answer and Robert's clarification.
By default, you sinatra runs in development mode, not production mode. In development mode, the default host to which sinatra will bind is 'localhost', meaning only the local machine can interact with it.
Once you specify '-e production' your sinatra webapp is running in production mode, where the default host it binds to is 0.0.0.0, which means that it can interact with all others.
Alternatively, if you want to remain in development, specify '-o 0.0.0.0'