Search code examples
ruby-on-railsrubythin

Rails Server dies with EAFNOSUPPORT - Windows 10, Ruby 2.4, Rails 4.2,Thin


I can run rake tasks and a console, but the development server dies a few moments after launch before I make any requests to it.

It seems like it has something to do with IPV6 based on the ::1 address but I can't find where I can do anything about that.

Any ideas?

C:\Rails Projects\cfhtrust>rails s
[factory_girl warning, below]
=> Booting Thin
=> Rails 4.2.11 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
[eventmachine warnings below]
Thin web server (v1.7.2 codename Bachmanity)
Maximum connections set to 1024
Listening on localhost:3000, CTRL+C to stop
Exiting
C:/Ruby24/lib/ruby/gems/2.4.0/gems/eventmachine-1.2.7/lib/em/pure_ruby.rb:1054:in `bind': An address incompatible with the requested protocol was used. - bind(2) for [::1]:3000 (Errno::EAFNOSUPPORT)
        from C:/Ruby24/lib/ruby/gems/2.4.0/gems/eventmachine-1.2.7/lib/em/pure_ruby.rb:1054:in `start_server'
        from C:/Ruby24/lib/ruby/gems/2.4.0/gems/eventmachine-1.2.7/lib/em/pure_ruby.rb:185:in `start_tcp_server'
        from C:/Ruby24/lib/ruby/gems/2.4.0/gems/eventmachine-1.2.7/lib/eventmachine.rb:531:in `start_server'
        from C:/Ruby24/lib/ruby/gems/2.4.0/gems/thin-1.7.2/lib/thin/backends/tcp_server.rb:16:in `connect'
        from C:/Ruby24/lib/ruby/gems/2.4.0/gems/thin-1.7.2/lib/thin/backends/base.rb:63:in `block in start'
        from C:/Ruby24/lib/ruby/gems/2.4.0/gems/eventmachine-1.2.7/lib/eventmachine.rb:1545:in `event_callback'
        from C:/Ruby24/lib/ruby/gems/2.4.0/gems/eventmachine-1.2.7/lib/em/pure_ruby.rb:571:in `block in run_timers'
        from C:/Ruby24/lib/ruby/2.4.0/set.rb:699:in `each'
        from C:/Ruby24/lib/ruby/2.4.0/set.rb:699:in `each'
        from C:/Ruby24/lib/ruby/gems/2.4.0/gems/eventmachine-1.2.7/lib/em/pure_ruby.rb:568:in `run_timers'
        from C:/Ruby24/lib/ruby/gems/2.4.0/gems/eventmachine-1.2.7/lib/em/pure_ruby.rb:551:in `block in run'
        from C:/Ruby24/lib/ruby/gems/2.4.0/gems/eventmachine-1.2.7/lib/em/pure_ruby.rb:547:in `loop'
        from C:/Ruby24/lib/ruby/gems/2.4.0/gems/eventmachine-1.2.7/lib/em/pure_ruby.rb:547:in `run'
        from C:/Ruby24/lib/ruby/gems/2.4.0/gems/eventmachine-1.2.7/lib/em/pure_ruby.rb:144:in `run_machine'
        from C:/Ruby24/lib/ruby/gems/2.4.0/gems/eventmachine-1.2.7/lib/eventmachine.rb:195:in `run'
        from C:/Ruby24/lib/ruby/gems/2.4.0/gems/thin-1.7.2/lib/thin/backends/base.rb:73:in `start'
        from C:/Ruby24/lib/ruby/gems/2.4.0/gems/thin-1.7.2/lib/thin/server.rb:162:in `start'
        from C:/Ruby24/lib/ruby/gems/2.4.0/gems/rack-1.6.2/lib/rack/handler/thin.rb:19:in `run'
        from C:/Ruby24/lib/ruby/gems/2.4.0/gems/rack-1.6.2/lib/rack/server.rb:286:in `start'
        from C:/Ruby24/lib/ruby/gems/2.4.0/gems/railties-4.2.11/lib/rails/commands/server.rb:80:in `start'
        from C:/Ruby24/lib/ruby/gems/2.4.0/gems/railties-4.2.11/lib/rails/commands/commands_tasks.rb:80:in `block in server'
        from C:/Ruby24/lib/ruby/gems/2.4.0/gems/railties-4.2.11/lib/rails/commands/commands_tasks.rb:75:in `tap'
        from C:/Ruby24/lib/ruby/gems/2.4.0/gems/railties-4.2.11/lib/rails/commands/commands_tasks.rb:75:in `server'
        from C:/Ruby24/lib/ruby/gems/2.4.0/gems/railties-4.2.11/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
        from C:/Ruby24/lib/ruby/gems/2.4.0/gems/railties-4.2.11/lib/rails/commands.rb:17:in `<top (required)>'
        from bin/rails:4:in `require'
        from bin/rails:4:in `<main>'

I see these warnings when I start the server, but I see the same things when I start a Rails console and then the Rails console works, so that gives me some reason to believe these are not the actual show-stoppers killing the server.

DEPRECATION WARNING: The factory_girl gem is deprecated. Please upgrade to factory_bot. See https://github.com/thoughtbot/factory_bot/blob/v4.9.0/UPGRADE_FROM_FACTORY_GIRL.md for further instructions. (called from require at C:/Ruby24/lib/ruby/site_ruby/2.4.0/bundler/runtime.rb:81)
C:/Ruby24/lib/ruby/gems/2.4.0/gems/eventmachine-1.2.7/lib/em/pure_ruby.rb:467: warning: already initialized constant EventMachine::TimerFired
C:/Ruby24/lib/ruby/gems/2.4.0/gems/eventmachine-1.2.7/lib/em/pure_ruby.rb:469: warning: already initialized constant EventMachine::ConnectionData
C:/Ruby24/lib/ruby/gems/2.4.0/gems/eventmachine-1.2.7/lib/em/pure_ruby.rb:471: warning: already initialized constant EventMachine::ConnectionUnbound
C:/Ruby24/lib/ruby/gems/2.4.0/gems/eventmachine-1.2.7/lib/em/pure_ruby.rb:473: warning: already initialized constant EventMachine::ConnectionAccepted
C:/Ruby24/lib/ruby/gems/2.4.0/gems/eventmachine-1.2.7/lib/em/pure_ruby.rb:475: warning: already initialized constant EventMachine::ConnectionCompleted
C:/Ruby24/lib/ruby/gems/2.4.0/gems/eventmachine-1.2.7/lib/em/pure_ruby.rb:477: warning: already initialized constant EventMachine::LoopbreakSignalled
C:/Ruby24/lib/ruby/gems/2.4.0/gems/eventmachine-1.2.7/lib/em/pure_ruby.rb:479: warning: already initialized constant EventMachine::ConnectionNotifyReadable
C:/Ruby24/lib/ruby/gems/2.4.0/gems/eventmachine-1.2.7/lib/em/pure_ruby.rb:481: warning: already initialized constant EventMachine::ConnectionNotifyWritable
C:/Ruby24/lib/ruby/gems/2.4.0/gems/eventmachine-1.2.7/lib/em/pure_ruby.rb:483: warning: already initialized constant EventMachine::SslHandshakeCompleted
C:/Ruby24/lib/ruby/gems/2.4.0/gems/eventmachine-1.2.7/lib/em/pure_ruby.rb:485: warning: already initialized constant EventMachine::SslVerify
C:/Ruby24/lib/ruby/gems/2.4.0/gems/eventmachine-1.2.7/lib/em/pure_ruby.rb:487: warning: already initialized constant EventMachine::EM_PROTO_SSLv2
C:/Ruby24/lib/ruby/gems/2.4.0/gems/eventmachine-1.2.7/lib/em/pure_ruby.rb:489: warning: already initialized constant EventMachine::EM_PROTO_SSLv3
C:/Ruby24/lib/ruby/gems/2.4.0/gems/eventmachine-1.2.7/lib/em/pure_ruby.rb:491: warning: already initialized constant EventMachine::EM_PROTO_TLSv1
C:/Ruby24/lib/ruby/gems/2.4.0/gems/eventmachine-1.2.7/lib/em/pure_ruby.rb:493: warning: already initialized constant EventMachine::EM_PROTO_TLSv1_1
C:/Ruby24/lib/ruby/gems/2.4.0/gems/eventmachine-1.2.7/lib/em/pure_ruby.rb:495: warning: already initialized constant EventMachine::EM_PROTO_TLSv1_2

Solution

  • I got the server running by switching to Puma and forcing it to IPv6 by using

    rails s -b [::]
    

    That might be a workaround instead of an answer. I suspect there is a corporate setting or perhaps firewall issue that blocks 127.0.0.1:3000 but I never got a clear answer on that.