Reputation: 19150
I’m using Rails 4.2.3 on Mac Yosemite. I’m trying to set up an alias for my local machine, so that I can enter “http://devbox.example.com:3000/” in my browser and have my local Rails instance serve the pages. But I can’t seem to do this. I have set this up in my /etc/hosts file
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
127.0.0.1 devbox.example.com
But when I start my Rails server (“rails s”), I can visit “http:///localhost:3000/“ just fine, but when I try and visit “http://devbox.example.com:3000/“, I get an “Unable to connect” error. What’s stranger, when the server is running, pinging the alias I have set up resolves to 127.0.0.1 …
localhost:myapp davea$ ping devbox.example.com
PING devbox.example.com (127.0.0.1): 56 data bytes
64 bytes from 127.0.0.1: icmp_seq=0 ttl=64 time=0.056 ms
What do I need to do in Rails to get my server to run on the alias I have set up?
Upvotes: 1
Views: 1618
Reputation: 84
rails s -b 0.0.0.0
. The -b
or bind option will allow you to set the ip address that the rails server binds to. If you had multiple connectors, you could set a specific one.
Upvotes: 4