Could not find connection using haystack elasticsearch.

When I run python manage.py rebuild_index , I get the following error:

Failed to delete Elasticsearch index: HTTPConnectionPool (host = '127.0.0.1', port = 9200): maximum number of attempts with url: / haystack exceeded (caused by: [Errno 111] Connection rejected)

My elastics search setting:

 > HAYSTACK_CONNECTIONS = { > 'default': { > 'ENGINE': 'haystack.backends.elasticsearch_backend.ElasticsearchSearchEngine', > 'URL': 'http://127.0.0.1:9200/', > 'INDEX_NAME': 'haystack', > }, } 

It is worth mentioning that I once indexed my data, and everything was fixed, but I do not know why, when I returned to the project and restarted the django project, it went wrong!

thanks for the help

+4
source share
2 answers

It looks like you forgot to start ElasticSearch when you returned to the project because the local connection was refused.

If you installed from a .deb file, it must be connected to the Ubuntu service command so that you can run it with

 $ sudo service elasticsearch start 

If you used tarball, make sure you start it with something like:

 $ bin/elasticsearch 

For more information, see the installation documentation http://www.elasticsearch.org/guide/reference/setup/installation/

+6
source

In my case, this was resolved by increasing the default timeout from 10 to 60 seconds.

 HAYSTACK_CONNECTIONS = { 'default': { 'ENGINE': 'haystack.backends.elasticsearch_backend.ElasticsearchSearchEngine', 'URL': 'http://127.0.0.1:9200/', 'INDEX_NAME': 'index_name', 'TIMEOUT' : 60 }, 
+2
source

Source: https://habr.com/ru/post/1502010/


All Articles