byebug: Foreman / Passenger - address is already in use

I’ve followed the tutorial and added this to config/development.rb:

require 'byebug'
Byebug.wait_connection = true
Byebug.start_server('localhost', 4000)

When starting foreman, I get the error below. I’ve tried many different ports, the error message is always the same =(.

foreman start
11:05:01 web.1    | started with pid 1313
11:05:01 worker.1 | started with pid 1314
11:05:01 clock.1  | started with pid 1315
11:05:03 web.1    | =============== Phusion Passenger Standalone web server started ===============
11:05:03 web.1    | PID file: /Users/michaelimstepf/Dev/web-app/tmp/pids/passenger.5000.pid
11:05:03 web.1    | Log file: /Users/michaelimstepf/Dev/web-app/log/passenger.5000.log
11:05:03 web.1    | Environment: development
11:05:03 web.1    | Accessible via: http://0.0.0.0:5000/
11:05:03 web.1    | 
11:05:03 web.1    | You can stop Phusion Passenger Standalone by pressing Ctrl-C.
11:05:03 web.1    | Problems? Check https://www.phusionpassenger.com/documentation/Users%20guide%20Standalone.html#troubleshooting
11:05:03 web.1    | ===============================================================================
11:05:06 web.1    | App 1348 stdout: 
11:05:11 web.1    | App 1348 stdout: 
11:05:11 web.1    | [ 2015-05-01 11:05:11.4894 1329/0x109438000 App/Implementation.cpp:287 ]: Could not spawn process for application /Users/michaelimstepf/Dev/web-app: An error occured while starting up the preloader.
11:05:11 web.1    |   Error ID: fb5bc44c
11:05:11 web.1    |   Error details saved to: /var/folders/dy/rqh4m_713fx624wgtlvcwy840000gn/T//passenger-error-bgFXQJ.html
11:05:11 web.1    |   Message from application: Address already in use - bind(2) for "localhost" port 5051 (Errno::EADDRINUSE)
11:05:11 web.1    |   /Users/michaelimstepf/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/byebug-4.0.5/lib/byebug/remote.rb:52:in `initialize'
11:05:11 web.1    |   /Users/michaelimstepf/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/byebug-4.0.5/lib/byebug/remote.rb:52:in `new'
11:05:11 web.1    |   /Users/michaelimstepf/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/byebug-4.0.5/lib/byebug/remote.rb:52:in `start_control'
11:05:11 web.1    |   /Users/michaelimstepf/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/byebug-4.0.5/lib/byebug/remote.rb:31:in `start_server'
11:05:11 web.1    |   /Users/michaelimstepf/Dev/web-app/config/environments/development.rb:6:in `block in <top (required)>'
11:05:11 web.1    |   /Users/michaelimstepf/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/railtie.rb:210:in `instance_eval'
11:05:11 web.1    |   /Users/michaelimstepf/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/railtie.rb:210:in `configure'
11:05:11 web.1    |   /Users/michaelimstepf/Dev/web-app/config/environments/development.rb:4:in `<top (required)>'
11:05:11 web.1    |   /Users/michaelimstepf/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:274:in `require'
11:05:11 web.1    |   /Users/michaelimstepf/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:274:in `block in require'
11:05:11 web.1    |   /Users/michaelimstepf/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:240:in `load_dependency'
11:05:11 web.1    |   /Users/michaelimstepf/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:274:in `require'
11:05:11 web.1    |   /Users/michaelimstepf/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/engine.rb:598:in `block (2 levels) in <class:Engine>'
11:05:11 web.1    |   /Users/michaelimstepf/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/engine.rb:597:in `each'
11:05:11 web.1    |   /Users/michaelimstepf/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/engine.rb:597:in `block in <class:Engine>'
11:05:11 web.1    |   /Users/michaelimstepf/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/initializable.rb:30:in `instance_exec'
11:05:11 web.1    |   /Users/michaelimstepf/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/initializable.rb:30:in `run'
11:05:11 web.1    |   /Users/michaelimstepf/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/initializable.rb:55:in `block in run_initializers'
11:05:11 web.1    |   /Users/michaelimstepf/.rbenv/versions/2.2.2/lib/ruby/2.2.0/tsort.rb:226:in `block in tsort_each'
11:05:11 web.1    |   /Users/michaelimstepf/.rbenv/versions/2.2.2/lib/ruby/2.2.0/tsort.rb:348:in `block (2 levels) in each_strongly_connected_component'
11:05:11 web.1    |   /Users/michaelimstepf/.rbenv/versions/2.2.2/lib/ruby/2.2.0/tsort.rb:420:in `block (2 levels) in each_strongly_connected_component_from'
11:05:11 web.1    |   /Users/michaelimstepf/.rbenv/versions/2.2.2/lib/ruby/2.2.0/tsort.rb:429:in `each_strongly_connected_component_from'
11:05:11 web.1    |   /Users/michaelimstepf/.rbenv/versions/2.2.2/lib/ruby/2.2.0/tsort.rb:419:in `block in each_strongly_connected_component_from'
11:05:11 web.1    |   /Users/michaelimstepf/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/initializable.rb:44:in `each'
11:05:11 web.1    |   /Users/michaelimstepf/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/initializable.rb:44:in `tsort_each_child'
11:05:11 web.1    |   /Users/michaelimstepf/.rbenv/versions/2.2.2/lib/ruby/2.2.0/tsort.rb:413:in `call'
11:05:11 web.1    |   /Users/michaelimstepf/.rbenv/versions/2.2.2/lib/ruby/2.2.0/tsort.rb:413:in `each_strongly_connected_component_from'
11:05:11 web.1    |   /Users/michaelimstepf/.rbenv/versions/2.2.2/lib/ruby/2.2.0/tsort.rb:347:in `block in each_strongly_connected_component'
11:05:11 web.1    |   /Users/michaelimstepf/.rbenv/versions/2.2.2/lib/ruby/2.2.0/tsort.rb:345:in `each'
11:05:11 web.1    |   /Users/michaelimstepf/.rbenv/versions/2.2.2/lib/ruby/2.2.0/tsort.rb:345:in `call'
11:05:11 web.1    |   /Users/michaelimstepf/.rbenv/versions/2.2.2/lib/ruby/2.2.0/tsort.rb:345:in `each_strongly_connected_component'
11:05:11 web.1    |   /Users/michaelimstepf/.rbenv/versions/2.2.2/lib/ruby/2.2.0/tsort.rb:224:in `tsort_each'
11:05:11 web.1    |   /Users/michaelimstepf/.rbenv/versions/2.2.2/lib/ruby/2.2.0/tsort.rb:203:in `tsort_each'
11:05:11 web.1    |   /Users/michaelimstepf/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/initializable.rb:54:in `run_initializers'
11:05:11 web.1    |   /Users/michaelimstepf/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/application.rb:352:in `initialize!'
11:05:11 web.1    |   /Users/michaelimstepf/Dev/web-app/config/environment.rb:5:in `<top (required)>'
11:05:11 web.1    |   config.ru:3:in `require'
11:05:11 web.1    |   config.ru:3:in `block in <main>'
11:05:11 web.1    |   /Users/michaelimstepf/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rack-1.6.0/lib/rack/builder.rb:55:in `instance_eval'
11:05:11 web.1    |   /Users/michaelimstepf/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rack-1.6.0/lib/rack/builder.rb:55:in `initialize'
11:05:11 web.1    |   config.ru:1:in `new'
11:05:11 web.1    |   config.ru:1:in `<main>'
11:05:11 web.1    |   /Users/michaelimstepf/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/passenger-5.0.6/helper-scripts/rack-preloader.rb:111:in `eval'
11:05:11 web.1    |   /Users/michaelimstepf/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/passenger-5.0.6/helper-scripts/rack-preloader.rb:111:in `preload_app'
11:05:11 web.1    |   /Users/michaelimstepf/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/passenger-5.0.6/helper-scripts/rack-preloader.rb:157:in `<module:App>'
11:05:11 web.1    |   /Users/michaelimstepf/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/passenger-5.0.6/helper-scripts/rack-preloader.rb:29:in `<module:PhusionPassenger>'
11:05:11 web.1    |   /Users/michaelimstepf/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/passenger-5.0.6/helper-scripts/rack-preloader.rb:28:in `<main>'
11:05:11 web.1    | 
11:05:11 web.1    | 
11:05:11 web.1    | [ 2015-05-01 11:05:11.4980 1329/0x109122000 age/Hel/Req/CheckoutSession.cpp:252 ]: [Client 1-1] Cannot checkout session because a spawning error occurred. The identifier of the error is fb5bc44c. Please see earlier logs for details about the error.

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Reactions: 1
  • Comments: 27 (12 by maintainers)

Most upvoted comments

I have had the same issue.

The problem is that you have (like me) multiple rails processes starting in your Procfile. As every one of them runs the initializer, at least the second process crashes, as the port is (legitimately) already in use . So what I did as a workaround is something like this, to prevent following processes to crash:

Byebug.start_server('localhost', 9999) rescue nil

Don’t forget that the process you want to debug has to be obviously the first one in your Procfile. However - if your first process is too lazy you can still get into some other race condition… 😉

Andreas

$ foreman start
foreman: command not found

Remember that I’m in front of my computer, not in front of yours.