Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Foreman / Passenger - address is already in use #141

Closed
migu0 opened this issue May 1, 2015 · 27 comments
Closed

Foreman / Passenger - address is already in use #141

migu0 opened this issue May 1, 2015 · 27 comments

Comments

@migu0
Copy link

migu0 commented May 1, 2015

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.
@deivid-rodriguez
Copy link
Owner

@michaelimstepf Sorry for taking this long to reply. If I ever use foreman again, I'll have a look at it.

@migu0
Copy link
Author

migu0 commented May 18, 2015

Thanks. I think the problem is with Passenger, not foreman.

@deivid-rodriguez
Copy link
Owner

Ok, changing the title to reflect that.

@deivid-rodriguez deivid-rodriguez changed the title Foreman - address is already in use Foreman / Passenger - address is already in use May 18, 2015
@deivid-rodriguez
Copy link
Owner

@michaelimstepf Are you still getting this issue with latest byebug? Could you some steps I can run to reproduce it?

Thanks!

@migu0
Copy link
Author

migu0 commented Aug 31, 2015

@deivid-rodriguez Thx, would be great if you could look into since we waste so much time stopping foreman and booting the super slow Webrick server every time we need to debug locally.

gem install foreman
# Gemfile.lock
byebug (6.0.2)
passenger (5.0.16)

# config/development.rb
require 'byebug'
Byebug.wait_connection = true
Byebug.start_server('localhost', 4000)  # see also http://stackoverflow.com/questions/22794176/how-to-use-byebug-with-a-remote-process-e-g-pow

# Procfile
web: bundle exec passenger start -p $PORT --max-pool-size 2
worker: bundle exec sidekiq -c 2 -v
clock: bundle exec clockwork lib/clock.rb
Michaels-MacBook-Pro:web-app michaelimstepf$ foreman start
14:18:51 web.1    | started with pid 44933
14:18:51 worker.1 | started with pid 44934
14:18:51 clock.1  | started with pid 44935
14:18:52 web.1    | =============== Phusion Passenger Standalone web server started ===============
14:18:52 web.1    | PID file: /Users/michaelimstepf/Dev/web-app/tmp/pids/passenger.5000.pid
14:18:52 web.1    | Log file: /Users/michaelimstepf/Dev/web-app/log/passenger.5000.log
14:18:52 web.1    | Environment: development
14:18:52 web.1    | Accessible via: http://0.0.0.0:5000/
14:18:52 web.1    | 
14:18:52 web.1    | You can stop Phusion Passenger Standalone by pressing Ctrl-C.
14:18:52 web.1    | Problems? Check https://www.phusionpassenger.com/library/admin/standalone/troubleshooting/
14:18:52 web.1    | ===============================================================================
14:18:54 web.1    | App 44961 stdout: 
14:19:00 web.1    | App 44961 stdout: 
14:19:01 web.1    | [ 2015-08-31 14:19:01.0510 44945/0x10b535000 App/Implementation.cpp:303 ]: Could not spawn process for application /Users/michaelimstepf/Dev/web-app: An error occured while starting up the preloader.
14:19:01 web.1    |   Error ID: e8d09aaa
14:19:01 web.1    |   Error details saved to: /var/folders/dy/rqh4m_713fx624wgtlvcwy840000gn/T//passenger-error-fph0bM.html
14:19:01 web.1    |   Message from application: Address already in use - bind(2) for "localhost" port 4001 (Errno::EADDRINUSE)
14:19:01 web.1    |   /Users/michaelimstepf/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/byebug-6.0.2/lib/byebug/remote.rb:58:in `initialize'
14:19:01 web.1    |   /Users/michaelimstepf/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/byebug-6.0.2/lib/byebug/remote.rb:58:in `new'
14:19:01 web.1    |   /Users/michaelimstepf/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/byebug-6.0.2/lib/byebug/remote.rb:58:in `start_control'
14:19:01 web.1    |   /Users/michaelimstepf/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/byebug-6.0.2/lib/byebug/remote.rb:36:in `start_server'
14:19:01 web.1    |   /Users/michaelimstepf/Dev/web-app/config/environments/development.rb:61:in `block in <top (required)>'
14:19:01 web.1    |   /Users/michaelimstepf/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/railties-4.2.4/lib/rails/railtie.rb:210:in `instance_eval'
14:19:01 web.1    |   /Users/michaelimstepf/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/railties-4.2.4/lib/rails/railtie.rb:210:in `configure'
14:19:01 web.1    |   /Users/michaelimstepf/Dev/web-app/config/environments/development.rb:3:in `<top (required)>'
14:19:01 web.1    |   /Users/michaelimstepf/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/activesupport-4.2.4/lib/active_support/dependencies.rb:274:in `require'
14:19:01 web.1    |   /Users/michaelimstepf/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/activesupport-4.2.4/lib/active_support/dependencies.rb:274:in `block in require'
14:19:01 web.1    |   /Users/michaelimstepf/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/activesupport-4.2.4/lib/active_support/dependencies.rb:240:in `load_dependency'
14:19:01 web.1    |   /Users/michaelimstepf/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/activesupport-4.2.4/lib/active_support/dependencies.rb:274:in `require'
14:19:01 web.1    |   /Users/michaelimstepf/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/railties-4.2.4/lib/rails/engine.rb:598:in `block (2 levels) in <class:Engine>'
14:19:01 web.1    |   /Users/michaelimstepf/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/railties-4.2.4/lib/rails/engine.rb:597:in `each'
14:19:01 web.1    |   /Users/michaelimstepf/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/railties-4.2.4/lib/rails/engine.rb:597:in `block in <class:Engine>'
14:19:01 web.1    |   /Users/michaelimstepf/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/railties-4.2.4/lib/rails/initializable.rb:30:in `instance_exec'
14:19:01 web.1    |   /Users/michaelimstepf/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/railties-4.2.4/lib/rails/initializable.rb:30:in `run'
14:19:01 web.1    |   /Users/michaelimstepf/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/railties-4.2.4/lib/rails/initializable.rb:55:in `block in run_initializers'
14:19:01 web.1    |   /Users/michaelimstepf/.rbenv/versions/2.2.3/lib/ruby/2.2.0/tsort.rb:226:in `block in tsort_each'
14:19:01 web.1    |   /Users/michaelimstepf/.rbenv/versions/2.2.3/lib/ruby/2.2.0/tsort.rb:348:in `block (2 levels) in each_strongly_connected_component'
14:19:01 web.1    |   /Users/michaelimstepf/.rbenv/versions/2.2.3/lib/ruby/2.2.0/tsort.rb:420:in `block (2 levels) in each_strongly_connected_component_from'
14:19:01 web.1    |   /Users/michaelimstepf/.rbenv/versions/2.2.3/lib/ruby/2.2.0/tsort.rb:429:in `each_strongly_connected_component_from'
14:19:01 web.1    |   /Users/michaelimstepf/.rbenv/versions/2.2.3/lib/ruby/2.2.0/tsort.rb:419:in `block in each_strongly_connected_component_from'
14:19:01 web.1    |   /Users/michaelimstepf/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/railties-4.2.4/lib/rails/initializable.rb:44:in `each'
14:19:01 web.1    |   /Users/michaelimstepf/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/railties-4.2.4/lib/rails/initializable.rb:44:in `tsort_each_child'
14:19:01 web.1    |   /Users/michaelimstepf/.rbenv/versions/2.2.3/lib/ruby/2.2.0/tsort.rb:413:in `call'
14:19:01 web.1    |   /Users/michaelimstepf/.rbenv/versions/2.2.3/lib/ruby/2.2.0/tsort.rb:413:in `each_strongly_connected_component_from'
14:19:01 web.1    |   /Users/michaelimstepf/.rbenv/versions/2.2.3/lib/ruby/2.2.0/tsort.rb:347:in `block in each_strongly_connected_component'
14:19:01 web.1    |   /Users/michaelimstepf/.rbenv/versions/2.2.3/lib/ruby/2.2.0/tsort.rb:345:in `each'
14:19:01 web.1    |   /Users/michaelimstepf/.rbenv/versions/2.2.3/lib/ruby/2.2.0/tsort.rb:345:in `call'
14:19:01 web.1    |   /Users/michaelimstepf/.rbenv/versions/2.2.3/lib/ruby/2.2.0/tsort.rb:345:in `each_strongly_connected_component'
14:19:01 web.1    |   /Users/michaelimstepf/.rbenv/versions/2.2.3/lib/ruby/2.2.0/tsort.rb:224:in `tsort_each'
14:19:01 web.1    |   /Users/michaelimstepf/.rbenv/versions/2.2.3/lib/ruby/2.2.0/tsort.rb:203:in `tsort_each'
14:19:01 web.1    |   /Users/michaelimstepf/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/railties-4.2.4/lib/rails/initializable.rb:54:in `run_initializers'
14:19:01 web.1    |   /Users/michaelimstepf/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/railties-4.2.4/lib/rails/application.rb:352:in `initialize!'
14:19:01 web.1    |   /Users/michaelimstepf/Dev/web-app/config/environment.rb:5:in `<top (required)>'
14:19:01 web.1    |   /Users/michaelimstepf/Dev/web-app/config.ru:3:in `require'
14:19:01 web.1    |   /Users/michaelimstepf/Dev/web-app/config.ru:3:in `block in <main>'
14:19:01 web.1    |   /Users/michaelimstepf/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/rack-1.6.4/lib/rack/builder.rb:55:in `instance_eval'
14:19:01 web.1    |   /Users/michaelimstepf/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/rack-1.6.4/lib/rack/builder.rb:55:in `initialize'
14:19:01 web.1    |   /Users/michaelimstepf/Dev/web-app/config.ru:1:in `new'
14:19:01 web.1    |   /Users/michaelimstepf/Dev/web-app/config.ru:1:in `<main>'
14:19:01 web.1    |   /Users/michaelimstepf/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/passenger-5.0.16/helper-scripts/rack-preloader.rb:107:in `eval'
14:19:01 web.1    |   /Users/michaelimstepf/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/passenger-5.0.16/helper-scripts/rack-preloader.rb:107:in `preload_app'
14:19:01 web.1    |   /Users/michaelimstepf/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/passenger-5.0.16/helper-scripts/rack-preloader.rb:153:in `<module:App>'
14:19:01 web.1    |   /Users/michaelimstepf/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/passenger-5.0.16/helper-scripts/rack-preloader.rb:29:in `<module:PhusionPassenger>'
14:19:01 web.1    |   /Users/michaelimstepf/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/passenger-5.0.16/helper-scripts/rack-preloader.rb:28:in `<main>'
14:19:01 web.1    | 
14:19:01 web.1    | 
14:19:01 web.1    | [ 2015-08-31 14:19:01.0606 44945/0x10afd4000 age/Cor/Req/CheckoutSession.cpp:252 ]: [Client 1-1] Cannot checkout session because a spawning error occurred. The identifier of the error is e8d09aaa. Please see earlier logs for details about the error.

@deivid-rodriguez
Copy link
Owner

Thanks, but it's not enough. I'm in front of my terminal, which commands do I run to trigger the error?

Also, did you make sure that the port is not already in use?

@migu0
Copy link
Author

migu0 commented Aug 31, 2015

Thx for looking into this.

Just run 'foreman start' to boot the server. I tried lots of different
ports, none of them worked.

On Mon, 31 Aug 2015 21:59 David Rodríguez [email protected] wrote:

Thanks, but it's not enough. I'm in front of my terminal, which commands
do I run to trigger the error?

Also, did you make sure that the port is not already in use?


Reply to this email directly or view it on GitHub
#141 (comment)
.

@deivid-rodriguez
Copy link
Owner

$ foreman start
foreman: command not found

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

@migu0
Copy link
Author

migu0 commented Aug 31, 2015

Sure. Please follow the code outlined in my post earlier including gem install foreman and the contents of the Procfile.

Thx for your help.

It's almost midnight here, I can quickly connect on Skype if you like, otherwise I can reply tmr. Thx

@migu0
Copy link
Author

migu0 commented Aug 31, 2015

As noted in the Gemfile.lock above, gem passenger needs to be in the Gemfile as well.

@deivid-rodriguez
Copy link
Owner

Of course, I'm just trying emphasize that the code outlined is not enough for me. I want you to do all the setup job for me and create a sample application that reproduces the error. You are currently the only person getting the error so it's very likely that I'll take the time to set all this up for myself and still won't be able to reproduce it.

@migu0
Copy link
Author

migu0 commented Aug 31, 2015

Got it.

You're going to hate me but I created a sample app and couldn't reproduce the issue. Strangely enough, I have the problem and both my personal laptop and my work laptop and my colleague has the same issue. I'll dig into it tomorrow, it might have to do with some temp file that Passenger is writing that we can delete to free ports, not sure yet.

Anyways, sorry for wasting your time, I would not have posted it if it didn't occur on 3 laptops.

Thanks for your help.

@migu0 migu0 closed this as completed Aug 31, 2015
@deivid-rodriguez
Copy link
Owner

Don't worry about it! Please reopen if you figure out a way I can see the issue for myself.

@migu0
Copy link
Author

migu0 commented Sep 4, 2015

I've tried a few things on two different laptops but still can't figure it out. Here's the sample app: https://github.com/michaelimstepf/byebug, would be awesome if you could have a look at it.

I can get it work if I either
a) take out the worker in the Procfile or
b) take out all debugger statements and the Byebug reference in config/development.rb

But in our dev setup we need to be able to debug (non background tasks) while having background tasks running.

Steps to reproduce:

  1. Clone repo: https://github.com/michaelimstepf/byebug
  2. run bundle
  3. gem install foreman
  4. Install redis brew install redis
  5. Start redis redis-server /usr/local/etc/redis.conf
  6. Start server foreman start
  7. Start byebug byebug -R localhost:8888 (or foreman run byebug -R localhost:8888?)
  8. Open localhost:5000/high_scores
  9. It never gets to the debugger statement in ApplicationController

@migu0 migu0 reopened this Sep 4, 2015
@mollat
Copy link

mollat commented Nov 11, 2015

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

@migu0
Copy link
Author

migu0 commented Nov 12, 2015

Thanks for your reply. I've added the rescue nil statement to the test repo https://github.com/michaelimstepf/byebug. It no longer crashes when booting up the server with foreman start but the byebug calls don't appear on when starting with byebug -R localhost:8888. Any hints?

@mollat
Copy link

mollat commented Nov 12, 2015

I think the byebug/remote function is a bit difficult to handle for larger rails apps, as you can hardly control in which process it will be initialized (and will therefore be functional).

I tried the following (Procfile):

redis: redis-server --bind 127.0.0.1
web: MAIN_THREAD=true bundle exec rails s -e development -p 3000 -b 192.168.2.164
websockets: bundle exec puma -p 1443 -b tcp://192.168.2.164 cable/config.ru
sidekiq: bundle exec sidekiq

and then in initializer/byebug.rb:

if Rails.env.development? && ENV['MAIN_THREAD'] == 'true'
  Byebug.wait_connection = true
  Byebug.start_server('localhost', 9999)
end

Now I even have two listening processes:

$ netstat -na | grep LISTEN
tcp        0      0 127.0.0.1:3000          0.0.0.0:*               LISTEN     
tcp        0      0 127.0.0.1:9999          0.0.0.0:*               LISTEN     
tcp        0      0 127.0.0.1:10000         0.0.0.0:*               LISTEN     

But hitting a 'byebug' command crashes the app with an Errno::EPIPE (Broken pipe) exception.

However - lacking time I switched back to console debugging for the moment.

Wishing you more luck,
Andreas

@migu0
Copy link
Author

migu0 commented Nov 16, 2015

Thanks @mollat. @deivid-rodriguez What are your thoughts on this, is byebug definitely not suitable for debugging apps that have background workers, cron jobs, etc?

@deivid-rodriguez
Copy link
Owner

I think it is suitable, it just needs some love.

@os97673
Copy link
Contributor

os97673 commented Nov 16, 2015

JFYI: for RubyMine we are starting "dispatcher": server which receives requests from newly created processes and give them port they can use to connect to debugger.

@deivid-rodriguez
Copy link
Owner

@os97673 Thanks for that information, that might help future contributors! 😄

@migu0
Copy link
Author

migu0 commented Nov 17, 2015

Thanks guys, is there any workaround or hack we can use in the meantime?

@deivid-rodriguez
Copy link
Owner

Not that I know of.

@sleungcy
Copy link

sleungcy commented Jan 7, 2016

I am getting the exact same issues.. whenever I start the rails console, spring will also try to start an instance of byebug server.

@sleungcy
Copy link

sleungcy commented Jan 7, 2016

I was able to connect to the byebug server and get a stack trace if i make sure the pid listening to the port is in fact the rails server and not spring..

If I killed the byebug remote client process during a debugging session, I will receive a Broken pipe error from the front end for further hits on the 'byebug' command. Digging into netstat, there seems to be a stuck close_wait port that does not release until the front end is restarted.. (such as touch tmp/restart in passenger)

tcp 0 0 127.0.0.1:1048 0.0.0.0:* LISTEN
tcp 1 0 127.0.0.1:1048 127.0.0.1:34196 CLOSE_WAIT

Why is it stuck waiting? Is it because its still "debugging"?

@deivid-rodriguez
Copy link
Owner

Hi everyone, some issues about remote debugging are getting fixed in #406, and also a remote_byebug shortcut is being added that automatically require "byebug/core" to make it less likely to run into the require "byebug" instead of require "byebug/core" gotcha. Feel free to give the branch a try and let me know!

@ryanb
Copy link

ryanb commented Sep 24, 2021

I ran into this today. It was due to Spring starting the Byebug server in the background. What I ended up doing is using the remote_byebug method instead of starting the server ahead of time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants