Search code examples
pythondjangoelasticsearchdjango-haystackcloud9-ide

Django-Haystack elasticsearch config in cloud 9


I'm trying to install django-haystack in my django project which I'm working on in the Cloud 9 online IDE. The documentation for django-haystack says to add this configuration to settings.py:

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

But trying to run ./manage.py rebuild_index results in an error: "Connection Refused".

If I try changing the URL value to http://myproject-username.c9users.io:9200/ I also get an error: "ConnectTimeoutError".

Does anyone know what the correct configuration would be, or if I'm missing a step?


Solution

  • Cloud9 requires you to run apps on port 8080, 8081, or 8082.

    If you use 8080, you can access your app from https://myproject-username.c9users.io. If you use the other two ports then you'll access it from https://myproject-username.c9users.io:8081 or https://myproject-username.c9users.io:8082.

    Find your elasticsearch.yml configuration file, and in the Network section uncomment http.port and set the value to one of the allowed ports (probably 8081 or 8082 if your main app is running on 8080).