0
votes

below is the console error message I get when trying to run "rails s" on a vagrant VM. It exits with all this error message, first line being /home/vagrant/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/net/http.rb:878:in `initialize': Connection refused - connect(2) (Errno::ECONNREFUSED)

Not sure what is going on here ...

Thank you so much


config\initializers\tire.rb subdomain = ""

if Rails.env.alpha?
  subdomain = ".alpha."
end

if Rails.env.development?
  Tire.configure { logger 'log/elasticsearch_development.log', :level => 'debug' }
else
  Tire.configure { logger "log/elasticsearch.#{Rails.env.to_s.downcase}.log" }
end

prefix = "org.#{Rails.application.class.parent_name.downcase}#{subdomain}_#{Rails.env.to_s.downcase}"
Tire::Model::Search.index_prefix(prefix)


def get_indices_for_env(prefix)
  aliases = Tire::Configuration.client.get(Tire::Configuration.url + '/_aliases').body
  global_indices = MultiJson.load(aliases).keys

  all_indices = global_indices.select do |index|
    index.start_with? prefix
  end
  all_indices.freeze
end

ALL_INDICES = get_indices_for_env(prefix)

error message


vagrant@precise32:/vagrant$ bundle exec rails s => Booting WEBrick => Rails 3.2.17 application starting in development on http://x.x.x.x:3000 => Call with -d to detach => Ctrl-C to shutdown server Exiting /home/vagrant/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/net/http.rb:878:in initialize': Connection refused - connect(2) (Errno::ECONNREFUSED) from /home/vagrant/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/net/http.rb:878:in open' from /home/vagrant/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/net/http.rb:878:in block in connect' from /home/vagrant/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/timeout.rb:52:in timeout' from /home/vagrant/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/net/http.rb:877:in connect' from /home/vagrant/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/net/http.rb:862:in do_start' from /home/vagrant/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/net/http.rb:851:in start' from /home/vagrant/.rvm/gems/ruby-2.0.0-p247/gems/rest-client-1.6.7/lib/restclient/request.rb:172:in transmit' from /home/vagrant/.rvm/gems/ruby-2.0.0-p247/gems/rest-client-1.6.7/lib/restclient/request.rb:64:in execute' from /home/vagrant/.rvm/gems/ruby-2.0.0-p247/gems/tire-0.6.2/lib/tire/http/client.rb:11:in get' from /vagrant/config/initializers/tire.rb:20:in get_indices_for_env' from /vagrant/config/initializers/tire.rb:29:in' from /home/vagrant/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-3.2.17/lib/active_support/dependencies.rb:245:in load' from /home/vagrant/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-3.2.17/lib/active_support/dependencies.rb:245:in block in load' from /home/vagrant/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-3.2.17/lib/active_support/dependencies.rb:236:in load_dependency' from /home/vagrant/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-3.2.17/lib/active_support/dependencies.rb:245:in load' from /home/vagrant/.rvm/gems/ruby-2.0.0-p247/gems/railties-3.2.17/lib/rails/engine.rb:593:in block (2 levels) in <class:Engine>' from /home/vagrant/.rvm/gems/ruby-2.0.0-p247/gems/railties-3.2.17/lib/rails/engine.rb:592:in each' from /home/vagrant/.rvm/gems/ruby-2.0.0-p247/gems/railties-3.2.17/lib/rails/engine.rb:592:in block in <class:Engine>' from /home/vagrant/.rvm/gems/ruby-2.0.0-p247/gems/railties-3.2.17/lib/rails/initializable.rb:30:in instance_exec' from /home/vagrant/.rvm/gems/ruby-2.0.0-p247/gems/railties-3.2.17/lib/rails/initializable.rb:30:in run' from /home/vagrant/.rvm/gems/ruby-2.0.0-p247/gems/railties-3.2.17/lib/rails/initializable.rb:55:in block in run_initializers' from /home/vagrant/.rvm/gems/ruby-2.0.0-p247/gems/railties-3.2.17/lib/rails/initializable.rb:54:in each' from /home/vagrant/.rvm/gems/ruby-2.0.0-p247/gems/railties-3.2.17/lib/rails/initializable.rb:54:in run_initializers' from /home/vagrant/.rvm/gems/ruby-2.0.0-p247/gems/railties-3.2.17/lib/rails/application.rb:136:in initialize!' from /home/vagrant/.rvm/gems/ruby-2.0.0-p247/gems/railties-3.2.17/lib/rails/railtie/configurable.rb:30:in method_missing' from /vagrant/config/environment.rb:5:in <top (required)>' from /vagrant/config.ru:3:inrequire' from /vagrant/config.ru:3:in block in <main>' from /home/vagrant/.rvm/gems/ruby-2.0.0-p247/gems/rack-1.4.5/lib/rack/builder.rb:51:in instance_eval' from /home/vagrant/.rvm/gems/ruby-2.0.0-p247/gems/rack-1.4.5/lib/rack/builder.rb:51:in initialize' from /vagrant/config.ru:innew' from /vagrant/config.ru:in <main>' from /home/vagrant/.rvm/gems/ruby-2.0.0-p247/gems/rack-1.4.5/lib/rack/builder.rb:40:in eval' from /home/vagrant/.rvm/gems/ruby-2.0.0-p247/gems/rack-1.4.5/lib/rack/builder.rb:40:in parse_file' from /home/vagrant/.rvm/gems/ruby-2.0.0-p247/gems/rack-1.4.5/lib/rack/server.rb:200:in app' from /home/vagrant/.rvm/gems/ruby-2.0.0-p247/gems/railties-3.2.17/lib/rails/commands/server.rb:46:in app' from /home/vagrant/.rvm/gems/ruby-2.0.0-p247/gems/rack-1.4.5/lib/rack/server.rb:304:in wrapped_app' from /home/vagrant/.rvm/gems/ruby-2.0.0-p247/gems/rack-1.4.5/lib/rack/server.rb:254:in start' from /home/vagrant/.rvm/gems/ruby-2.0.0-p247/gems/railties-3.2.17/lib/rails/commands/server.rb:70:in start' from /home/vagrant/.rvm/gems/ruby-2.0.0-p247/gems/railties-3.2.17/lib/rails/commands.rb:55:in block in <top (required)>' from /home/vagrant/.rvm/gems/ruby-2.0.0-p247/gems/railties-3.2.17/lib/rails/commands.rb:50:in tap' from /home/vagrant/.rvm/gems/ruby-2.0.0-p247/gems/railties-3.2.17/lib/rails/commands.rb:50:in <top (required)>' from script/rails:6:inrequire' from script/rails:6:in `'

1
Take a look at the code: 'config/initializers/tire.rb:20' based on the error it is making an http request and failinghouse9
@house9 thanks house9, I edited the original post with the ruby file in config/initializers/tire.rb but not exactly sure what the problem is ... I'm seeing this Rails project for the 1st time, handed down from somebody else through Vagrant.Terry Bu
Start with commenting out that file and see if you can get rails to start uphouse9
@house9 thanks, commenting out that stupid file worked but now i have another problem though ... maybe I can deal with it on another question but would you have any idea with this? The rails server puts up error that says: ActiveRecord::StatementInvalid in PostsController#homepage Mysql2::Error: Unknown column 'posts.status' in 'where clause': SELECT posts.* FROM posts WHERE posts.status = 'PUBLISHED' AND posts.post_type = 'About' AND (title LIKE 'About Ourgoods%') ORDER BY created_at DESC LIMIT 1.... I have the database snapshot in a *.sql file, so I guess i have to hook it upTerry Bu
@house9 never mind, I figured it out, thank you!!!!Terry Bu

1 Answers

1
votes

Like house9 commented above, I basically commented out the entire ruby file that was causing me the problems.

And then I had a problem starting the Rails server because it couldn't find a database. So it threw an ActiveRecord error:

ActiveRecord::StatementInvalid in PostsController#homepage Mysql2::Error: Unknown column 'posts.status' in 'where clause': SELECT posts.* FROM posts WHERE posts.status = 'PUBLISHED' AND posts.post_type = 'About' AND (title LIKE 'About Ourgoods%') ORDER BY created_at DESC LIMIT 1....

After connecting a .sql file that I had to the Rails app (following instructions from: How do I connect a mysql database file to a local ruby on rails application), and running rake db:migrate, I finally got rails s working!