This error means that your logstash cannot connect to your Elasticsearch.
Are they running on the same machine/container? Using localhost means that logstash and elasticsearch are running on the same place.
How are you running both logstash and elasticsearch?
You need to share your entire elasticsearch.yml, this is not enough, also, if you disabled security you can remove the user, password and ssl settings from your logstash output.
This configuration in logstash.yml is irrelevant for this issue, this is related to the Logstash monitoring API only.
But where is your Logstash running? Inside a container or on the host machine? And where is your Elasticsearch running? Inside a container or on the host machine? You need to provide these informations, also provide how are you running it, with docker compose? Using docker cli?
If they are running in different containers, then you cannot use localhost in the logstash elasticsearch output.
localhost means the same host or the same container, since they are running in different containers you need to use the container name or the host ip if you are exposing the ports.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.