Exception in thread : All hosts are unreachable


I am intermittently getting the error while searching the index:
Exception in thread “main” com.algolia.search.exceptions.AlgoliaRetryException: All hosts are unreachable

SearchResult<?> result = index.search(query);

After sometime it works fine without any code change. Can anyone please let me know what could be the issue?

Thanks and regards


Is there any update on the above mentioned issue I am facing?

Hi @indranil.basu,

You will generally encounter this error when the credentials you are using i.e Application ID and the API key are wrong.

Hope this helps!


Hi Harsh,

The same credentials work most of the times, but there are periods when it does not. The same program runs fine most of the time, however sometimes it just fails as mentioned in the ticket.

The issue is intermittent, but when it does it leads to bad customer experience.

Thanks and regards

Hi @indranil.basu ,

As you have mentioned that the error is showing up intermittently, it maybe that your connection is getting timed out.

As such, could you try increasing the timeouts as described by Algolia below and see if the problem still persists.