Development server doesn't work after updating Puma in Ruby on Rails app

1.5k Views Asked by At

I'll preface this with letting you know that I'm quite a novice when it comes to programming, so I apologise if the solution is straightforward.

I have a Ruby on Rails app on 'Codeanywhere' which is an Online cloud-based IDE, I'm using Puma to view the server in development. Usually, it's as easy as entering in 'Rails s' and then clicking the preview button to view my app in development.

However, after doing a 'bundle update', this no longer works. I enter in 'Rails s' and it says the server has started, but when I click the preview button, it says it can't connect and there's no server running. I've narrowed it down and the 'update' that is causing this issue is either the updating of the Rails gem itself, or more likely the updating of the Puma gem, which is the gem that controls this function.

I've tried "rails s --binding=0.0.0.0" but that hasn't worked either, it seems to just be the update that breaks it, but I need the update as it's a security vulnerability. If I roll back the update, it works fine, but I need the updated gems.

Rails version before update: 5.2.1 Puma version before update: 3.11

Rails version after update: 5.2.4 Puma version after update: 3.12.2

Rails S output is:

=> Booting Puma
=> Rails 5.2.4 application starting in development
=> Run `rails server -h` for more startup options
Puma starting in single mode...
* Version 3.12.2 (ruby 2.5.1-p57), codename: Llamas in Pajamas
* Min threads: 5, max threads: 5
* Environment: development
* Listening on tcp://localhost:3000
Use Ctrl-C to stop
^C- Gracefully stop

Some insight would be greatly appreciated.

1

There are 1 best solutions below

0
On

I just hit this after updating to Puma 3.12.2, too (Rails 6 in case anyone cares).

Reviewing lib/puma/dsl.rb, I found 2 ways to change my Rails app's config/puma.rb to specify 0.0.0.0.

Both

set_default_host '0.0.0.0'
port        ENV.fetch("PORT") { 3000 }

and

port        ENV.fetch("PORT") { 3000 }, '0.0.0.0'

make it print

[...]
* Listening on tcp://0.0.0.0:3000
Use Ctrl-C to stop
[...]

on startup and work/listen accordingly for me.