Reputation: 12391
I created a file with name server.rb
require 'bundler' ; Bundler.require
get '/hello-world' do
"Hello World!"
end
when i access it as curl http://localhost:4567
from command line I can easily see Hello World!
but when I access via browser as http://172.16.16.14:4567
172.16.16.14
is the ip of the local server and when I hit http://172.16.16.14/
I can see the default page of nginx.
I get
This site can’t be reached
172.16.16.14 refused to connect.
Upvotes: 1
Views: 53
Reputation: 742
As mentioned in the comments by @miknik it's quite possible that it has to do with the servers bind
option.
Documented on Sintara website: http://sinatrarb.com/configuration.html#bind---server-hostname-or-ip-address
This will allow connections from any host:
set :bind, '0.0.0.0'
Here's the actual PR for making the default bind address localhost
rather than 0.0.0.0
which will allow connections from any host. https://github.com/sinatra/sinatra/pull/634
Upvotes: 1