Reputation: 834
I have a simple Sinatra server that I run through textmate but I can't access from another computer on the same network.
I'm running Ruby 1.9.3p327 and Sinatra 1.4.1 on a Mac OS 10.8.3. Firewall is disabled.
I tested the same scenario on different networks and computers.
The computer responds to simple pings but when I try to telnet port 4567 I can't establish a connection.
Upvotes: 44
Views: 15701
Reputation: 1481
I'm chiming in with a little extra information that may help people like me banging their heads against the wall.
I'm on a Windows machine, not a Mac, and I had to open the port I was using (default for Sinatra is 4567) to the public (even though I'm on a university network).
To do this in Windows 10:
Now another thing to consider is who can access your web server. If you want anyone, then pick public. I don't know for sure (and would love other's input) how to get only devices on the same public network to connect. You can also allow specific IPs through, but for that I suggest doing some research on your own.
Upvotes: 0
Reputation: 79783
There was a recent commit to Sinatra that changed the default listen address to localhost
from 0.0.0.0
in development mode due to security concerns.
In order to explicitly allow access from the network, you need to either run your app in another mode (e.g. production), or set the bind
option to 0.0.0.0
.
You can do this from the command line using the built in server using the -o
option:
$ ./my_sinatra_file.rb -o 0.0.0.0
Upvotes: 91
Reputation: 26979
Make sure the sinatra server is not listening on only the localhost (127.0.0.1) ip address.
Upvotes: 5