Connection Refused when trying to connect using REST template client from outside

Hi, I have elastic search cluster of 2 nodes and trying to call the REST API from a spring boot application using a rest client. It's giving me connection refused error every time. It works when I set the
Since this is not recommended way for production server, what will work for production?

Elastic search cluster is working fine. My old settings which used to work with ES 6.6.1 is as follows: local,host-1

The same setting does not work with ES 7.0.1

Why it's not recommended? Could you clarify?

Hi David,
I found out in some of the discussion forums that having the value is not advisable for security reasons for PROD environment. Is it okay to use in PROD environments?

Why it doesn't work when I bind to localhost and hostname both?

You should not expose your cluster on internet for sure. Without any security, definitely.
But if you are in a backend layer, that's ok to expose elasticsearch to other backend machines like your own application.
If your application is not running on the same machine, then you need to define to be reachable from the other application.

I wonder if you should write it that way though: host-1, _local_ 

BTW this can be a bad practice as we recommend having 3 master eligible nodes in the cluster.

My Applications are on the cloud. Both Elastic search and client are deployed on cloud. That's the reason I was trying to avoid using ES nodes has a public IP and can be accessed from outside. Any suggestions how I can make it work?

Also I tried your suggestion of bringing the hostname before "local" and it did not work for me. I am getting the same connection refused error.

Does cloud mean not secured for you? I mean that you can secure elasticsearch from 6.8 and 7.1.

Also I tried your suggestion of bringing the hostname before " local " and it did not work for me. I am getting the same connection refused error.

What are the logs then?

BTW did you look at
Cloud by elastic is one way to have access to all features, all managed by us. Think about what is there yet like Security, Monitoring, Reporting, SQL, Canvas, APM, Logs UI, Infra UI and what is coming next :slight_smile: ... It starts at around $15 per month IIRC.

We have our own hosted cloud environment where we want to run the Elastic search. Upgrading from v 6.6.1 to v 7.0.1.

Before the change:

publish_address {}, bound_addresses {}, {[::1]:9200}, {}

After the change:

publish_address {}, bound_addresses {}, {[::1]:9200}, {}

I just want to understand if there is any other setting that I can try instead of in to make it work? That means, I should be able to call the ES API from a rest client of my application.

So your application should be able to connect to:

  • (from any machine)
  • [::1]:9200 (if the app runs on the same machine)
  • (if the app runs on the same machine)

Is it the case?

If you look at the, I am setting it to 'local' and hostname. I want to call the API using the hostname:9200, not the IP address. local,

In logs:
publish_address {}, bound_addresses {}, {[::1]:9200}, {}

From my app I am calling which is throwing Connection Refused exception.

What is the IP address of Is it or a public IP address? If the later, that's why it does not work.

When I do a nslookup I see this (from my app VM).

[root@host-1 opc]# nslookup

Non-authoritative answer:

I resolves to 2 IPs, but one of them is the one which is published by ES. Not sure why it doesn't work.

Could you try with instead of unless it's a typo? is just a dummy hostname :slight_smile:
I am using the correct one everywhere.

Any idea?

Any idea?

Running out ideas. And as I probably don't have the right names/IP may be you changed something in logs/config/... which makes that more complicated to diagnose.

Out of curiosity, are you exposing your cluster on internet and that's why you don't want to share the real logs, config?

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.