-E network.host doesn't work in VM

I'm trying to run ElasticSearch and view the webpage from a different machine.

On my Debian desktop,
elasticsearch-5.0.1/bin/elasticsearch -E network.host=100.96.149.173 works. I can access machine_hostname:9200.

But running the same command in a Google Compute Engine VM gives:

[2018-02-20T21:45:54,967][WARN ][o.e.b.ElasticsearchUncaughtExceptionHandler] [] uncaught exception in thre
ad [main]
org.elasticsearch.bootstrap.StartupException: BindTransportException[Failed to bind to [9300-9400]]; nested
: BindException[Cannot assign requested address];
at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:125) ~[elasticsearch-5.0.2.jar
:5.0.2]

It appears I need a different set of flags for VMs, but I can't figure out what.

Can you show the complete command you are using on the VM?

elasticsearch-5.0.2/bin/elasticsearch -E network.host=<external ip address>

I also tried discovery-gce plugin. If I do elasticsearch-5.0.2/bin/elasticsearch -E network.host=_gce:hostname_ or elasticsearch-5.0.2/bin/elasticsearch -E network.host=_gce_, I can curl against internal IP. But I want to curl against external IP. There doesn't seem to be a discovery-gce option for that.

elasticsearch-5.0.2/bin/elasticsearch -E network.host=0.0.0.0 should bind to all IPs.

That doesn't work. If I run that, I get:

[2018-02-20T22:15:58,641][INFO ][o.e.t.TransportService ] [urZOilT] publish_address {10.138.0.4:9300}, bo
und_addresses {[::]:9300}

10.138.0.4 is the VM's internal IP. I confirmed if I run curl 10.138.0.4:9200 inside VM works. But loading external_ip:9200 from outside the VM doesn't work.

This should be easy for you to reproduce, just create a Debian VM on Google Compute Engine.

Is the external address actually bound to an interface on the VM then?

Yes, I followed Running a basic Apache web server

The Hello World Apache server works: http://35.230.120.179/

ElasticSearch doesn't: http://35.230.120.179:9200/

What does ip link show or ifconfig -a show?

$ ip link show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1460 qdisc mq state UP mode DEFAULT group default qlen 1000
link/ether 42:01:0a:8a:00:04 brd ff:ff:ff:ff:ff:ff

$ ifconfig -a
-bash: ifconfig: command not found

Did you create a firewall rule allowing port 9200?

I thought I did, but it turns out my firewall rule only allowed 80. I changed to allow all ports.

elasticsearch-5.0.2/bin/elasticsearch -E network.host=0.0.0.0

now works. But

elasticsearch-5.0.2/bin/elasticsearch -E network.host=35.230.120.179

still gives BindTransportException error from above. Should I file a bug?

From googling, it seems like there might be a magic combination of flags that work, but I'm not sure what they are.

Should be easy for anyone to repro. Just create a Debian VM on Google Compute Engine. You should not be charged.

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