1

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.

Tun
  • 1,345
  • 13
  • 34
  • what are the rails version, puma version, puma config and output of `rails s`? please add in your question. – Tun Dec 17 '19 at 06:51
  • Okay I've done that now – Samreid Manez Dec 17 '19 at 10:21
  • It seems the server itself is working fine. I think you have to change config in CodeAnywhere. – Tun Dec 17 '19 at 13:45
  • Sometimes changing the Rails version in your Gemfile to something other than the version used to create the app can have consequences like this. Try just changing the Puma version to see if that is the problem. – Scott Schupbach Dec 17 '19 at 20:30

1 Answers1

1

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.

Bob Mazanec
  • 1,121
  • 10
  • 18