Cannot access local Sinatra server from another computer on same network

Thiago Peres picture Thiago Peres · Mar 28, 2013 · Viewed 15.1k times · Source

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.

Answer

matt picture matt · Mar 28, 2013

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