Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot access local Sinatra server from another computer on same network

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.

like image 265
Thiago Peres Avatar asked Mar 28 '13 15:03

Thiago Peres


1 Answers

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 
like image 101
matt Avatar answered Sep 17 '22 21:09

matt