Skip to main content

Connection errors

Are you getting “Impossible to connect”, “Unable to connect”, or “Unreachable hosts” errors? First, make sure the issue isn’t at your end:
  • Ensure you’re using the correct application ID and API key. Find these credentials on your Algolia dashboard.
  • Check for recent changes in your code.
  • Check the status of your data center provider.
If you’re using Firebase, you can only access Algolia from a paid Firebase tier.
If you can’t solve the problem yourself, contact the Algolia support team and provide them with the following information:
  • The name of the used gem and its version number
  • A code snippet to reproduce the issue
  • Error message or stack trace (if applicable)
  • The name of the Algolia index that’s causing problems
  • The exact UTC time of the event
  • If you can’t connect to the Algolia API from your browser, send the output from community.algolia.com/diag/.
  • If you can’t connect to the Algolia API from your servers, send the output from the following command (run on any affected server):
    curl -sL https://algolia.com/downloads/diag.sh > ./diag.sh && sudo ./diag.sh ALGOLIA_APPLICATION_ID
    
    Replace ALGOLIA_APPLICATION_ID with your Algolia application ID.

Raise or log exceptions

By default, this gem raises exceptions if something goes wrong.

Turn off indexing

Use the following code snippet to turn off indexing based on the current Rails environment. This can be helpful during testing or development.
Ruby
class Contact < ActiveRecord::Base
  include AlgoliaSearch

  algoliasearch disable_indexing: Rails.env.test? do
    # Algolia configuration
  end
end

class Contact < ActiveRecord::Base
  include AlgoliaSearch

  algoliasearch disable_indexing: Proc.new { Rails.env.test? || more_complex_condition } do
    # Algolia configuration
  end
end

Wait for indexing tasks

Indexing operations are asynchronous by default. During your tests, you might create models and then confirm if they were indexed in Algolia. To test this, it’s best to make your indexing synchronous.
Ruby
class Contact < ActiveRecord::Base
  include AlgoliaSearch

  algoliasearch synchronous: Rails.env.test? do
    # Algolia configuration
  end
end
Only use this option for testing.

Run tests for the Algolia Search gem

If you want to contribute to this gem, you can run the tests locally or let the CI run them when opening your pull requests. Before you run the tests, set the ALGOLIA_APPLICATION_ID and ALGOLIA_API_KEY environment variables. Since the tests create and delete indices, make sure the index names won’t affect your production.
I