1

I used to be using Whoosh as a search backend but now I'm switching to elasticsearch and trying to get things working.

When trying to rebuild the index I get the error:

requests.exceptions.ConnectionError: HTTPConnectionPool(host='localhost', port=8000): Max retries exceeded with url: /_bulk?op_type=create (Caused by <class 'socket.error'>: [Errno 61] Connection refused)

The following is in my settings.py:

HAYSTACK_CONNECTIONS = {
    'default': {
        'ENGINE': 'haystack.backends.elasticsearch_backend.ElasticsearchSearchEngine',
        'URL': 'http://localhost:8000/',
        'INDEX_NAME': 'haystack',
    },
}

My question is, what is URL used for and what do I put here? I'm running things locally for development and I'm deployed on Heroku.

1
  • the default port for ES is 9200. so unless you reconfigured it to 8000, just switch your port number. Commented Mar 28, 2013 at 23:35

1 Answer 1

4

The port should be 9200.

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

Also, you have to be sure that you are using the development version (2.0) of haystack.


Edit:

You probably want to make sure first that ElasticSearch is running by executing the following command:

curl -XGET 'http://127.0.0.1:9200/my_index/_mapping?pretty=1'
Sign up to request clarification or add additional context in comments.

12 Comments

I followed your answer, yet am still getting the error above.
If you are getting exactly the same error requests.exceptions.ConnectionError: HTTPConnectionPool(host='localhost', port=8000), then you placed the code in the wrong place (it should be in the settings of the project and depending which server you are using, you should restart it). If the error says requests.exceptions.ConnectionError: HTTPConnectionPool(host='localhost', port:9200), then either ElasticSearch is not running on your machine or, less probable, it is working on a different port.
You can test that ElasticSearch is running by executing the following command in the terminal: curl -XGET 'http://127.0.0.1:9200/my_index/_mapping?pretty=1'
I'm getting curl: (7) couldn't connect to host
You can change the port in elasticsearch.yml with the parameter http.port: 9199 (or any you think is free, see the file). In ubuntu, you should be able to find it here /etc/elasticsearch/elasticsearch.yml. Restart elasticsearch after changing the configuration file.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.