Skip to content

/etc/hosts can prevent puma from starting #1022

@AKovtunov

Description

@AKovtunov

After some coding got this error on running rails s:

puma-3.5.0/lib/puma/binder.rb:268:in `initialize': Address already in use - bind(2) for "127.0.0.1" port 3000 (Errno::EADDRINUSE)

My environment is:

$ rails -v       
Rails 5.0.0
$ ruby -v
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-linux]

I've tried:

  1. Create a new project - the same
  2. Checked Rails 4.2 - problem solved
  3. Reinstall rails 5 and ruby - the same problem
  4. lsof -wni tcp:3000 returns me nothing
  5. ps aux | grep "rails" - nothing
  6. ps aux | grep "puma" - nothing
  7. ps aux | grep "ruby" -nothing
  8. Use puma instead of rails s - problem solved
  9. Use RAILS_ENV=production bundle exec rails s - problem solved
  10. Use rails s -p 3001 - same problem, for other ports too

Monkey-patched https://github.com/puma/puma/blob/master/lib/puma/binder.rb and added pry.
Found that TCPServer.new is called few times with 127.0.0.1:3000

[3] pry(#<Puma::Binder>)> TCPSocket.gethostbyname "localhost"
=> ["localhost",
 [my hosts?],
 2,
 "127.0.0.1",
 "127.0.0.1",
 "127.0.0.1",
 "127.0.0.1",
 "127.0.0.1"]

I think this commit broke something for my machine 9b1de10#diff-4fd9276d9f86d7f4827e6ca4ab6b82b8
And I think this is related to the #782

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions