Curl -X GET Command Error

I am trying to install Elasticsearch on Ubuntu. When I run curl -X GET 'http://localhost:9200 I get an error: Empty Reply from Server.

I get this when the firewall is disabled and also when it is enabled.

I have adjusted the elasticsearch yml to uncomment port 9200 and also localhost

I have enabled allowed access to port 9200 but still get this error.

Anyone have any ideas?

Have you tried https instead of http?

Yes. When I do that I get a different error:

SSL Certificate Problem.

Also my Elasticsearch log shows that I cannot run it as root. I dont re-call trying to run elastic at all, I am at this point just trying to install it.

Which curl command you used and what is the response?

You need to pass the ca of your cluster using the cacert option or tell curl to ignore it using the -k option.

Command: curl -X GET https://localhost:9200

Error: curl: (60) SSL Certificate problem: self-signed certificate in certificate chain.

Curl failed to verify the legitimacy of the server and therefore could not establish a secure connection to it.

Just so you know these are the only commands ive run so far:

curl -fsSL https://artifacts.elastic.co/GPG-KEY-elasticsearch |sudo gpg --dearmor -o /usr/share/keyrings/elastic.gpg

echo "deb [signed-by=/usr/share/keyrings/elastic.gpg] https://artifacts.elastic.co/packages/8.x/apt stable main" | sudo tee -a /etc/apt/sources.list.d/elastic-7.x.list

sudo apt update

sudo apt install elasticsearch

sudo nano /etc/elasticsearch/elasticsearch.yml - to uncomment network host and port

sudo systemctl start elasticsearch

sudo systemctl enable elasticsearch

curl -X GET "localhost:9200"

What version (I am assukming 8.14) and how did you install.... looks like .deb

If you follow the official documentation, there is. a section on how to properly check if elasticsearch is runing here

BTW here are the official install instructions here

One of your commands is incorrect.....

echo "deb [signed-by=/usr/share/keyrings/elasticsearch-keyring.gpg] https://artifacts.elastic.co/packages/8.x/apt stable main" | sudo tee /etc/apt/sources.list.d/elastic-8.x.list
.../etc/apt/sources.list.d/elastic-8.x.list
...................................^

That was a copy / paste error. I ran that 2nd command with version 8.x, I just copied it into this chat from the original source incorrectly.

This command: curl --cacert /etc/elasticsearch/certs/http_ca.crt -u elastic:$ELASTIC_PASSWORD https://localhost:9200

Generates an error: curl: (77) error setting certificate file: /etc/elasticsearch/certs/http_ca.crt

I'm ripping everything out and starting fresh. I've been in IT for 20 years and installing Elastic is the most frustrating installation ive ever done.

Hi @dfir, apologies for the frustration...

If you install elasticsearch with all the defaults it will be secured with TLS on all ports and require authentication.

Thus curl will require https , a CA (because a self signed cert is generated) and authentication

The proper install procedure is here including how to test / check if running properly.

If you are cleaning / reinstalling make sure to clean up the data directories default /var/lib/elasticsearch if you don't there will be leftovers... that will interfere with your re-install...