Search code examples
portpuma

Puma does not seem to be opening the port it says it is


I'm developing a Rails app using Puma as the server on my local machine.

When I start the local server, the logs clearly indicate that Puma is opening a connection on localhost:3011:

=> Booting Puma
=> Rails 5.0.4 application starting in development on http://localhost:3011
=> Run `rails server -h` for more startup options
Puma starting in single mode...
* Version 3.9.1 (ruby 2.3.4-p301), codename: Private Caller
* Min threads: 5, max threads: 5
* Environment: development
* Listening on tcp://0.0.0.0:3000
Use Ctrl-C to stop

But when I run netstat to see the open port, port 3011 does not seem to be active:

kevin@kevin-devbox:~/Programming$ netstat -an | grep "3011"
(there is no output)
kevin@kevin-devbox:~/Programming$

How do I go about figuring out why my local server isn't opening the port it says it is?


Solution

  • The statements prefixed with => are coming from Rails, which sometimes doesn't get the right information. You can see the source for that log statement here.

    What really matters for binding ports is puma's bindings, which are revealed lower in the logs. You can see the source for that log here. You can make these work in a couple different ways:

    • Add the -p flag to the server command: rails s -p 3000
    • Add bind 'tcp://0.0.0.0:3000' to config/puma.rb.