Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Configuring elastic search to listen on 0.0.0.0:9200 (IPV4)

I've been trying to get elastic search (running behind a vpn) to listen to incoming requests from other machines on port 9200 using ipv4. Without modifying the default elasticsearch.yml, I ran netstat and received:

tcp6       0      0 127.0.0.1:9200          :::*                    LISTEN      8079/java
tcp6       0      0 ::1:9200                :::*                    LISTEN      8079/java
tcp6       0      0 127.0.0.1:9300          :::*                    LISTEN      8079/java
tcp6       0      0 ::1:9300                :::*                    LISTEN      8079/java

With the default settings, I could curl elastic search fine from inside the machine, but could not connect curl it from outside using curl -XGET [IP]:9200 (curl: (7) Failed to connect to [IP] port 9200: Connection refused)

I set network.host: 0.0.0.0, stopped and started elastic search sudo systemctl start elasticsearch.service and waited for a minute or two, but nothing was listening on 0.0.0.0:9200. I've also tried _local_:ipv4 and 0.0.0.0:ipv4 with no luck.


I added -Djava.net.preferIPv4Stack=true to jvm.options and now I am getting (with # network.port commented out):

tcp        0      0 127.0.0.1:9200          0.0.0.0:*               LISTEN      11131/java
tcp        0      0 127.0.0.1:9300          0.0.0.0:*               LISTEN      11131/java

I tried to set network.host: 0.0.0.0 again and restart the service but now I don't see it listening to any ports.

In the log files I receive an error [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 Setting cluster.initial_master_nodes: node-1 fixed it. Works.

like image 908
PanczerTank Avatar asked Sep 17 '25 07:09

PanczerTank


2 Answers

I added -Djava.net.preferIPv4Stack=true to jvm.options. Also added cluster.initial_master_nodes: node-1 to elasticsearch.yml.

like image 133
PanczerTank Avatar answered Sep 19 '25 06:09

PanczerTank


According to https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-network.html#network-interface-values you can add :ipv4 or :ipv6 suffixes to network.host, network.bind_host, network.publish_host, like: _en0:ipv4_.

like image 29
gavenkoa Avatar answered Sep 19 '25 05:09

gavenkoa