I just changed from thin
to puma
at the recommendation of Heroku. When I start my rails app using the puma server it responds:
=> Booting Puma
=> Rails 4.2.2 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
Puma 2.11.3 starting...
* Min threads: 0, max threads: 16
* Environment: development
* Listening on tcp://localhost:3000
However if I go to http://0.0.0.0:3000
in the browser, which was my old localhost with the thin server, it does not respond. However, if I open http://localhost:3000
, then it works. It appears that the definition of localhost has changed.
So, what is localhost
? In particular, what sort of object is it, how is it defined, how do I see the actual ip address, and why does puma change it?
If you're trying to get Rails to bind to a different ip, the way to do that is with the
-b
option. To bind it to0.0.0.0
instead of the Rails-defaultlocalhost
you'd want to run something along the lines ofrails s -b 0.0.0.0
Note: To be explicit, it may not be a bad idea to throw the
-p 3000
option in there too (sets the port), even though that default is not likely to change. More info on the available options can be found by runningrails s -h
as well.