2

I'm using Haystack to connect and interact with an installation of elasticsearch. Elasticsearch is installed on a different box to the main webserver.

I have set up HTTP authentication on the elasticsearch box using nginx. This is to stop unauthorised access to elasticsearch.

The Haystack config looks like this:

HAYSTACK_CONNECTIONS = {
    'default': {
        'ENGINE': 'haystack.backends.elasticsearch_backend.ElasticsearchSearchEngine',
        'URL': 'http://USERNAME:PASSWORD@DOMAIN:PORT/',
        'INDEX_NAME': 'haystack',
    },
}

With this set up I get a connection error:

elasticsearch.exceptions.ConnectionError: ConnectionError(('Connection aborted.',
gaierror(-2, 'Name or service not known'))) caused by: ProtocolError(('Connection
aborted.', gaierror(-2, 'Name or service not known')))

If I turn off HTTP authentication and update the URL correspondingly to http://DOMAIN:PORT/ it connects without a problem.

Could it be that Haystack (or elasticsearch-py (http://www.elasticsearch.org/guide/en/elasticsearch/client/python-api/current/) doesn't allow HTTP authentication to be used in the URL? I notice this is a problem with Solr - Solr authentication (using Django Haystack)

1 Answer 1

5

For others with the same problem, add kwargs to config:

'KWARGS': {
    'port': parsed.port,
    'http_auth': (parsed.username, parsed.password),
}

See: https://github.com/django-haystack/django-haystack/issues/1046

Sign up to request clarification or add additional context in comments.

Comments

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.