It seems your system cannot resolve localhost which sounds extremely weird and more like a misconfiguration on your system. Can you run curl 127.0.0.1:9200 - does it work?
That's your issue, it is completely unrelated to Elasticsearch.
You cannot reliably call the local server (localhost, 127.0.0.1) through a remote proxy used to go out on the internet.
Talk to your system administrator if you need assistance locally calling services on a server WITHOUT using a proxy or between servers in the same vlan.
Your user session on your servers is configured to send all HTTP/HTTPS traffic toward a remote proxy server, which breaks your call toward Elasticsearch which is installed locally on the server and which you are trying to call directly and locally.
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.