简体   繁体   中英

Getting error trying to start rails server on Vagrant vm

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://xxxx: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' f rom /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 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 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:in require' 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:in new' 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 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:in require' from script/rails:6:in `'

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!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM