Reputation: 11
I tried to execute the below python code
from datetime import datetime
from elasticsearch import Elasticsearch
es = Elasticsearch()
es.indices.create(index='my-index', ignore=400)
The last statement through the below connection error.
ConnectionError: ConnectionError(<urllib3.connection.HTTPConnection object at
0x0000020DC5EEF6D8>: Failed to establish a new connection: [WinError 10061] No
connection could be made because the target machine actively refused it) caused
by: NewConnectionError(<urllib3.connection.HTTPConnection object at
0x0000020DC5EEF6D8>: Failed to establish a new connection: [WinError 10061] No
connection could be made because the target machine actively refused it)
Upvotes: 1
Views: 6803
Reputation: 2321
It seems you have installed the only elasticsearch client library without installing the actual Elasticsearch in the computer. Thus first install Elasticsearch as follows. Download and Install
After you have downloaded a zip file(if you are using windows), into something like c:\elasticsearch-7.5.2
Go to a path like C:\elasticsearch-7.5.2\bin
and run elasticsearch.bat
Then go to your browser and run http://localhost:9200/, You should get a response like That means your elastic instance is running, so you can proceed with
es.indices.create(index='my-index', ignore=400)
In case you want a customization of the instance you can read out the tutorial Here
If you get an error of connection error while using the python elasticsearch it has already been answered Here
Upvotes: 2