15👍
Connection refused means just that, that the TCP connection to the Elasticsearch HTTP service was refused. The reason can be a number of things, for instance that you are using the wrong host or port for the HTTP endpoint, or that the elasticsearch node is not running for some reason.
Before you try to use Haystack, test that elasticsearch works by issuing a direct HTTP request with something like:
curl -X GET http://192.168.77.88:9200/_cat/indices
Where 192.168.77.88
is the IP address of your elasticsearch node, and 9200
is the TCP port. When that succeeds, check and double check that you have the same URL configuration in you Haystack config.
HAYSTACK_CONNECTIONS = {
'default': {
'ENGINE': 'haystack.backends.elasticsearch_backend.ElasticsearchSearchEngine',
'URL': 'http://192.168.77.88:9200/',
'INDEX_NAME': 'haystack',
},
}
2👍
I had the same problem. Just got it resolved by actually running the Elasticsearch on port 9200. If you are on windows, goto the bin directory of Elasticsearch installation and run the batch file of whichever Elasticsearch version you are using.
- Creating instances of Django proxy models from their base class
- Form.is_valid() returns false (django)
0👍
anton comment saved me!
I arrived here because I was trying to run elasticsearch-curator and I was getting the following error (even without Firewall or other connections blockers):
user@host:/opt/elasticsearch-curator$ curator_cli show-indices | more
2021-11-20 16:33:11,396 INFO Instantiating client object
2021-11-20 16:33:11,397 INFO Testing client connectivity
2021-11-20 16:33:11,403 ERROR HTTP N/A error: HTTPConnectionPool(host='127.0.0.1', port=9200): Max retries exceeded with url: / (Cause
d by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f5ca8ba7d60>: Failed to establish a new connection: [Errno 111] C
onnection refused'))
2021-11-20 16:33:11,403 CRITICAL Curator cannot proceed. Exiting.
Due a lot of other particularities in my lab, I have the line network.hosts: 10.0.0.134
in my /etc/elasticsearch/elasticsearch.yml, it means the private IP for that VM is fixed in the configuration, so my elasticsearch was not binding to all addresses as it should be in most cases.
The solution was to include an additional line network.bind_host: 0.0.0.0
in the file /etc/elasticsearch/elasticsearch.yml.
This way, the network session of my /etc/elasticsearch/elasticsearch.yml is the following:
# ---------------------------------- Network -----------------------------------
#
# By default Elasticsearch is only accessible on localhost. Set a different
# address here to expose this node on the network:
#
network.host: 10.0.0.134
#
# By default Elasticsearch listens for HTTP traffic on the first free port it
# finds starting at 9200. Set a specific HTTP port here:
#
http.port: 9200
#
network.bind_host: 0.0.0.0
#
# For more information, consult the network module documentation.
#
Now my elasticsearch-curator works great:
shaka@virgo:/opt/elasticsearch-curator$ sudo curator_cli show-indices | more
2021-11-20 17:30:02,294 INFO Instantiating client object
2021-11-20 17:30:02,295 INFO Testing client connectivity
/opt/python/3.9.4/lib/python3.9/site-packages/elasticsearch/connection/base.py:200: ElasticsearchWarning: Elasticsearch built-in security features are not enabled. Without authentication, your cluster could be accessible to anyone. See https://www.elastic.co/guide/en/elasticsearch/reference/7.15/security-minimal-setup.html to enable security.
2021-11-20 17:30:02,301 INFO Successfully created Elasticsearch client object with provided settings
/opt/python/3.9.4/lib/python3.9/site-packages/elasticsearch/connection/base.py:200: ElasticsearchWarning: this request accesses system indices: [.apm-agent-configuration, .apm-custom-link, .async-search, .kibana_7.14.0_001, .kibana_7.14.1_001, .kibana_7.15.0_001, .kibana_7.15.1_001, .kibana_7.15.2_001, .kibana_task_manager_7.14.0_001, .kibana_task_manager_7.14.1_001, .kibana_task_manager_7.15.0_001, .kibana_task_manager_7.15.1_001, .kibana_task_manager_7.15.2_001, .tasks], but in a future major version, direct access to system indices will be prevented by default
.apm-agent-configuration
.apm-custom-link
.async-search
.kibana-event-log-7.14.0-000001
I hope it helps someone facing the same problem.
- Django superuser doesn't have permission to delete models
- Django admin inline with custom queryset
- Run Django with URL prefix ("subdirectory") – App works, but URLs broken?
- Reading multidimensional arrays from a POST request in Django
- Overriding Django's RelatedManager methods
0👍
I make it sudo nano /etc/elasticsearch/elasticsearch.yml
network.host: 45.#.#.#
transport.host: localhost
It works for me
- Scheduling a regular event: Cron/Cron alternatives (including Celery)
- Logging Django SQL queries with DEBUG set to False
- How to add a default array of values to ArrayField?