11

I have set up Elastic Search 2.3.0 as a service in an Azure VM with Windows Server 2012 R2. I can access elastic search instance from within the server using

http://localhost:9200

but I cannot access from outside the server.

What have I tried?

  • Just for testing I have made the VM available outside the virtual network.
  • Opened up the port 9200 in Windows Firewall settings as an Inbound Traffic rule
  • Added an endpoint in Azure portal settings opening up port 9200

Tried this with VM Classic as well.

Also for testing whether the VM is alright, I had set up IIS in that machine, opened up the port 80. The default IIS page is accessible from outside.

Only thing I have not tried is setting ES in a Linux VM.

I can't find anything in the elasticsearch logs. On the browser (Chrome), there are no logs in the Network. It just spins, waiting for the server, and snaps with "ERR_EMPTY_RESPONSE".

Can anybody that had done this shed some light please?

UPDATE: Here is what I can see in netstat:

TCP    127.0.0.1:9200         machine-name:0       LISTENING
TCP    127.0.0.1:9300         machine-name:0       LISTENING
TylerH
  • 20,799
  • 66
  • 75
  • 101
droidbot
  • 937
  • 1
  • 10
  • 26

5 Answers5

27

Starting with ES 2.0, the elasticsearch process only binds to localhost, which explains why you can query ES from inside but not from the outside.

You need to change the following setting in your elasticsearch.yml configuration file:

network.host: 0.0.0.0
Val
  • 207,596
  • 13
  • 358
  • 360
  • Remember trying this too @Val. Added `network.host: A.B.C.D`, restarted the service. Still no luck. And its not reachable with localhost either. Also tried `network.host: ["A.B.C.D", "127.0.0.1", "[::1]"]`. No luck with that either. – droidbot Apr 04 '16 at 09:16
  • In this case, the entries are lost from netstat for ports 9200 and 9300. – droidbot Apr 04 '16 at 09:17
  • 1
    You need to use a real IP address, `A.B.C.D` is just an example, but it needs to be something like : 123.123.123.123 – Val Apr 04 '16 at 09:20
  • 2
    Please try with the value 0. – Val Apr 04 '16 at 09:26
  • Thnx @Val, but no luck with that. For your initial post, I see this in the error log: `Exception in thread "main" BindTransportException[Failed to bind to [9300-9400]] ; nested: ChannelException[Failed to bind to: /:9400]; nested: Bind Exception[Cannot assign requested address: bind];` – droidbot Apr 04 '16 at 09:30
  • Hang on.. I did something wrong.. I tried with `network.host: 0.0.0.0` and it works splendidly well.. – droidbot Apr 04 '16 at 09:35
  • Can you update your post with value 0 please, so I can mark it as an answer. – droidbot Apr 04 '16 at 09:36
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/108172/discussion-between-droidbot-and-val). – droidbot Apr 04 '16 at 11:06
  • network.host: 0.0.0.0 worked for me. I also restarted the service. Thanks! – Sebastian Ballarati Oct 11 '17 at 20:51
9

I had the same case. Looking in the log

tail -f /var/log/elasticsearch/NODE.log

I saw this:

 [NODE_NAME] publish_address {10.XXX.XXX.XXX:9300}, bound_addresses {10.XXX.XXX.XXX:9300}
 [NODE_NAME] bound or publishing to a non-loopback address, enforcing bootstrap checks
 [NODE_NAME] node validation exception
 [1] bootstrap checks failed
 [1]: the default discovery settings are unsuitable for production use; at least one of [discovery.seed_hosts, discovery.seed_providers, cluster.initial_master_nodes] must be configured
 [NODE_NAME] stopping ...
 [NODE_NAME] stopped

Solution:

Modify the archive /etc/elasticsearch/elasticsearch.yml in the line discorvery seed with this:

discovery.seed_hosts: ["127.0.0.1", "[::1]"]

Done.

Usman Maqbool
  • 3,351
  • 10
  • 31
  • 48
Grecko009
  • 91
  • 1
  • 1
2

I would suggest to set the network.host to special values

eg.

network.host: [_local_, _site_]

This works for me.

Amey Khadatkar
  • 414
  • 3
  • 16
  • I may be an ElasticSearch noob @Amey, sorry. Can you explain it a bit further please. For example, what do you mean by 'special values'? – droidbot Apr 04 '16 at 09:43
  • 1
    https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-network.html. This is the reference link for this. _local_ Any loopback addresses on the system, for example 127.0.0.1. _site_ Any site-local addresses on the system, for example 192.168.0.1 – Amey Khadatkar Apr 04 '16 at 10:00
2

Please note that for me success was achieved only after setting

http.host: 0.0.0.0

instead of

http.host: "localhost"
E.Big
  • 723
  • 6
  • 15
1

Resolved for me on Windows server 2012 with Elasticsearch 7.1.1 adding in C:\ProgramData\Elastic\Elasticsearch\config\elasticsearch.yml the following config:

http.host: 0.0.0.0
D. Pesc.
  • 196
  • 15