Search code examples
ruby-on-railshttptcppuma

Why Puma listen on 'tcp://localhost:3000' instead of 'http://localhost:3000'


I'm a Rails developer. There was a time I want to debug my Rails application runing in local on the mobile. So I tried to update my '/etc/hosts' to add the LAN ip(192.168.0.18) to localhost and make sure your laptop and mobile are connecting to the same LAN.

If I start my Rails application with 'Webwrick', it will listen on 'http://localhost:3000', then everything work well

But if I start my Rails application with 'Puma', it will listen on 'tcp://localhost:3000', and then I can't access the server by my LAN ip and port(192.168.0.18:3000)


Solution

  • The HTTP protocol works on top of TCP, HTTP adds format to the raw TCP, so it kind of means the same thing. Given that Webrick and Puma are different HTTP servers, they may refer to the same thing in different ways. I hope this will be the worst of your problems during your journey with Rails! Enjoy!