Search code examples
djangoelasticsearchdjango-haystack

haystack elasticsearch connection refused


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

Failed to clear Elasticsearch index: HTTPConnectionPool(host='127.0.0.1', port=9200): Max retries exceeded with url: /haystack (Caused by : [Errno 111] Connection refused)

My elasticsearch setting:

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

It is worth to mention that I have indexed my data once before and all things went correct but I dont know why when came back to project and restarted django project it went wrong!

Thanks in advence


Solution

  • It looks like you've forgotten to start ElasticSearch when you've returned to the project because the local connection is refused.

    If you installed from the .deb file, then it should be wired into Ubuntu's service command so you can start it with

    $ sudo service elasticsearch start
    

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

    $ bin/elasticsearch
    

    More information in Installation docs http://www.elasticsearch.org/guide/reference/setup/installation/