3

Recently we moved an application from rails 4 to rails 5.1.6 The issue which we are facing is that on starting the sunspot it shows as sunspot has started. But on reindex or on doing any database action, we are getting connection refused error

production:
  solr:
    hostname: localhost
    port: 8983
    log_level: WARNING
    path: /solr/default
development:
  solr:
    hostname: localhost
    port: 8983
    log_level: INFO
    path: /solr/default
test:
  solr:
    hostname: localhost
    port: 8983
    log_level: WARNING
    path: /solr/test

This is the process which we followed https://gist.github.com/1v/8a04e74ed1e86d8c52cf007f77b178be

Can anyone please help us on this

  • can you check on solr port, whether it is working or not? Means can you try querying on `http://localhost:8983/solr/query?q=test` for testing purpose – Rohit Lingayat Apr 05 '18 at 10:50

1 Answers1

1

Error 503 connection refused is usually linked to the following issues :

  • Solr server isn't actually launched (sunspot might tell you it is, don't listen to it, it is often a lie). To check if it was really launched, do rake sunspot:solr:start twice. It should fail the second time.
  • Solr server is launched on the wrong environment. Execute RAILS_ENV=your_environment bundle exec rake sunspot:solr:start. Put the RAILS_ENV at beginning, not at the end.
  • You solr server is launched twice on 2 different environment. You might even have a file write.lock in your solr folders. Delete this file if you have it. Check with ps aux | grep solr that you only have one solr running.

Usually, we just kill the solr processes and relaunch them, it is enough 90% of the time.

Edit : Another way of checking if solr actually run is to type rake sunspot:solr:run which run the process in the shell instead of the background. If it fails you should be able to see why.

Samuel-Zacharie Faure
  • 1,047
  • 11
  • 26