I am using "www.xip.io" as a DNS wildcard for testing on different devices. I set my primary domain to my IP address. I fire up a rails server with bundle exec rails server
and I go here www.<ip_address>.xip.io:3000
and notice my rails server doesn't respond.
However, if I bind my rails server to 0.0.0.0 like so bundle exec rails server -b 0.0.0.0
, it works! I don't understand what 0.0.0.0 is telling my server for this to work. Can someone make sense of this?
Binding to 0.0.0.0
tells the service to bind to all IP addresses on your machine. Rails server used to do this by default, but with 4.2 changed to binding only to localhost
.
Basically if it's only bound to localhost
then it will only respond locally to either localhost
or 127.0.0.1
which can't work through a DNS service because it's not a public IP address.
When you use 0.0.0.0
it will bind to localhost and to your routable IP address.
I think you need to use binding any time you're in a guest/virtual machine.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With