26

I'm using webrick to develop my rails app on Mac OS X Lion. I'm trying to access the site from another computer (for testing). The internal IP of my computer is 10.1.10.100.

Accessing 10.1.10.100 displays the page served by the apache server running on my computer.

Accessing 10.1.10.100:3000 times out, both from my computer and from another computer on the same network. I can ping 10.1.10.100. From my computer, loaclhost:3000 displays the app.

Is there are firewall I need to open up on Mac OS X or some other setting that needs to be applied?

Thanks

Tyler DeWitt
  • 23,366
  • 38
  • 119
  • 196

1 Answers1

50

While starting the webrick server specify the IP on which your rails application will run (10.1.10.100 in your case) using -b option, it binds Rails to the specified IP.

rails server -b 10.1.10.100 -p 3000
Kumar Akarsh
  • 4,954
  • 2
  • 20
  • 31
  • Replace "rails server" with "ruby script/server" in case you are using rails 2. – Kumar Akarsh Apr 09 '12 at 19:31
  • Strangely, this worked with thin too, even though when the port wasn't explicitly set, `netstat` showed it listening on all interfaces ("*") and `nmap` showed it open, but it didn't respond. – jwadsack Jun 09 '14 at 21:11
  • @Akarsh this worked for me, thanks! BTW, I've been using rails s for development purposes for some time and I was always able to access my app within the same network using machine IP. Do you know why I need this now? Maybe some different machine config? – Mário Carvalho Jan 07 '15 at 00:59
  • 3
    Instead of typing the IP each time, you can enter something like this: `rails s -b $(ipconfig getifaddr en0)` (just check if `en0` is actually your interface name, I based my comment on this: http://osxdaily.com/2010/11/21/find-ip-address-mac/). – Rafał Cieślak Mar 09 '15 at 13:48