chevron_left

Problem :

I am very new to Curl. I have recently started learning Curl.

Whenever I try to connect to the Elasticsearch using the below command

curl http://localhost:9200 it is working properly.

But when I try to run the following command curl http://IpAddress:9200 it is showing me below error

“Curl: (7) failed to connect to localhost port 9200: connection refused”

How can I resolve the above error?

Solution :

I also had a similar issue in the past refusing the connections on my 9200 port.
So I just checked the elasticsearch service status with the below command

sudo service elasticsearch status.

*After executing above command if it is presenting the error and it is related to Java, then mostly the problem is with your jvm memory.

If you want then you can also edit it in /etc/elasticsearch/jvm.options. My machine is having 1GB RAM memory on the Amazon environment,
So I kept my configurations as below:*

-Xms128m
-Xmx128m

After setting the above configuration and just restarting my elasticsearch service, it started working properly for me.

If you using the local firewall then Nmap and UFW checking will also be very useful for you.

After that you can test your Elasticsearch node is running or not by sending the HTTP request to the port 9200 on localhost using the command as shown below:

curl http://localhost:9200

I hope this will solve your problem
Thanks

More Posts

Failed to connect to remote vm. connection refused. connection refused: connect Alecxe01 - Nov 22
Javax.mail.messagingexception: could not connect to smtp host: localhost, port: 25, response: 421 Alecxe01 - Nov 22
PHP-SSL certificate error: unable to get local issuer certificate? Tushar Shuvro - Apr 8, 2020
File_get_contents('php //input') not working Alecxe01 - Nov 19
Trying to connect to host "smtp.gmail.com", port 465, isssl false. Alecxe01 - Nov 9
#2002 - no connection could be made because the target machine actively refused it. Farkhanda Athar - Apr 15, 2020
web server failed to start. port 8080 was already in use. SharadMagar450 - Aug 31
Server tomcat v9.0 server at localhost failed to start amna - May 24
Server tomcat v8.0 server at localhost failed to start. amna - May 24
Server tomcat v8.5 server at localhost failed to start. amna - May 24