Errno::ECONNREFUSED: Connection refused – connect(2) while connecting to a remote solr instance from Sunspot

Quickstart with Rails 3

Add to Gemfile:

gem 'sunspot_rails'
gem 'sunspot_solr' # optional pre-packaged Solr distribution for use in development

Bundle it!

bundle install

Generate a default configuration file:

rails generate sunspot_rails:install

If sunspot_solr was installed, start the packaged Solr distribution with:

bundle exec rake sunspot:solr:start # or sunspot:solr:run to start in foreground

Now that Sunspot knows how to index the Post model, we need to get the existing data into Solr. Any time a Post is created, updated, or destroyed, Sunspot::Rails will automatically make the change to the index; you only need to do a full reindex if you’ve added or changed a searchable definition for a model.

$ rake sunspot:reindex

If sunspot_solr was installed, start the packaged Solr distribution with:

jhjguxin@jhjguxin-Aspire-4750:~$ heroku run:detached rake sunspot:solr:start RAILS_ENV=production rake sunspot:solr:start --app francisjiang
or type:sunspot-solr start -- -p 8983 or sunspot-solr start -- -p 8983 -d data/solr/myapp

Try to start the solr

##with apache+solr+rails
jhjguxin@jhjguxin-virtual-machine:/var/www/enki$ sudo gem install sunspot_solr
Successfully installed escape-0.0.4
Successfully installed sunspot_solr-1.3.0
2 gems installed
Installing ri documentation for escape-0.0.4...
Installing ri documentation for sunspot_solr-1.3.0...
Installing RDoc documentation for escape-0.0.4...
Installing RDoc documentation for sunspot_solr-1.3.0...
jhjguxin@jhjguxin-virtual-machine:/var/www/enki$ sudo sunspot-solr start -- -p 8983 -d solr/data/
[sudo] password for jhjguxin:
java version "1.6.0_23"
OpenJDK Runtime Environment (IcedTea6 1.11pre) (6b23~pre11-0ubuntu1.11.10.1)
OpenJDK Client VM (build 20.0-b11, mixed mode, sharing)


rake sunspot:solr:start

rake sunspot:solr:stop
rake sunspot:reindex
rake sunspot:solr:run