Unable to create Index in Elastic Search

Hello, I'm trying to Use Elasticsearch to index the Wikipedia dump, but this error appears here

elastic_transport.ConnectionError: Connection error caused by: NewConnectionError(<elastic_transport._node._urllib3_chain_certs.HTTPSConnection object at 0x7f21c40cb100>: Failed to establish a new connection: [Errno 111] Connection refused)
WARNING:elastic_transport.node_pool:Node <Urllib3HttpNode(https://127.0.0.1:9200)> has failed for 7 times in a row, putting on 30 second timeout
WARNING:elastic_transport.transport:Retrying request after failure (attempt 2 of 3)

And my config is as follows:

'hostname': 'https://127.0.0.1:9200' ,
        # 'hostname': 'http://localhost:9200',
        'index_name': index_name,
        'keys': {'title': 'title', 'body': 'txt'},
        'timeout': 600,
        'retry_on_timeout': True,
        'maxsize': 24,
        'number_of_shards': 'default',
        'language': 'english',
        'file': "${workspaceFolder}/index.html"

What's happening. How do I fix it?

Hello and welcome to the forum. Hopefully we can get you started ...

There is your first problem.

Can you show some evidence that elasticsearch is up and running on the host?

How did you setup elasticsearch?

You don't need to supply any credentials to access elasticsearch?

I followed this prompt to install

cd data # This is the path where I installed elasticsearch
wget -O elasticsearch-8.15.0.tar.gz https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-8.15.0-linux-x86_64.tar.gz  # download Elasticsearch
tar zxvf elasticsearch-8.15.0.tar.gz
rm elasticsearch-8.15.0.tar.gz 
cd elasticsearch-8.15.0
nohup bin/elasticsearch &  # run Elasticsearch in background
cd ../..
python prep_elastic.py --data_path data/dpr/psgs_w100.tsv --index_name wiki  # build index

but when I run

nohup bin/elasticsearch

that prompt

nohup: ignoring input and appending output to 'nohup.out'

I thought it had started elasticsearch, and when I run "systemctl status elasticsearch" to checking if the Elasticsearch service is started, The following prompt appears. It confuses me.

System has not been booted with systemd as init system (PID 1). Can't operate.
Failed to connect to bus: Host is down

--------------------------------------------------------------------------------------------dividing line----------------------------------------------------------------------------------------------------------

"You don't need to supply any credentials to access elasticsearch?" Is this statement saying that I'm missing some credentials? But I'm also just following the project from the github repository, do I need to add any credentials?

Hi @pengdijie

First and foremost I think you should look at the elasticsearch installation documentation. You appear to making some significant assumption

nohup bin/elasticsearch &

From a tar.gz that will start elasticsearch with default security and authentication. You would have gotten authorization creds at startup the first time

You should follow this first

If you want to use systemctl you would need to I stall from a package

Either way I suggest you go back and look at the installation docs.

Then after you can curl propely to elasticsearch connecting via Python should be pretty straightforward.

As explained, you just need read and follow the standard installations instructions.

Is there a good reason to not use the most current release (8.17.3) ?

When you follow the installation instructions, then at some point you will learn that (for secure installation, even when using self-signed certificate) there is an "elastic" user, and a password, that you should use to connect to elasticsearch over HTTPS.

Elasticsearch is up and running when if you do this:

EUSER="elastic" EPASS="your-elastic-password" EHOST="localhost" EPORT="9200"
curl -s -k -u "${EUSER}:${EPASS}" "https://${EHOST}:${EPORT}"

you receive something like this:

{
  "name" : "macmini",
  "cluster_name" : "my-cluster",
  "cluster_uuid" : "xxxxxxxxxxxxxxxxxxxxx",
  "version" : {
    "number" : "8.17.2",
    "build_flavor" : "default",
    "build_type" : "tar",
    "build_hash" : "747663ddda3421467150de0e4301e8d4bc636b0c",
    "build_date" : "2025-02-05T22:10:57.067596412Z",
    "build_snapshot" : false,
    "lucene_version" : "9.12.0",
    "minimum_wire_compatibility_version" : "7.17.0",
    "minimum_index_compatibility_version" : "7.0.0"
  },
  "tagline" : "You Know, for Search"
}

Good luck. If you get further but still hit issues please just ask again.