PortGate

Resources · Port reference · port 9200

Port 9200 (Elasticsearch): what it is and how to secure it

Elasticsearch on port 9200 answers search and admin requests. An open 9200 leaks or loses every index.

Check command

sudo ss -tlnp | grep -E "9200|9300"

Copied.

Port 9200 is the Elasticsearch REST API, and it should only be reachable by your own app. An open 9200 without security lets anyone read every index, delete them all, or change the cluster settings. Many of the largest data leaks were exactly this.

What port 9200 is for

Elasticsearch, and its fork OpenSearch, take searches and indexing requests over HTTP on 9200. Port 9300 is the transport port that nodes use to talk to each other. Kibana and OpenSearch Dashboards usually sit on 5601.

Why an open Elasticsearch is dangerous

Version 8 turns security (users and TLS) on for new installs. Older versions, upgrades that kept old settings, and many Docker examples run with security off. With security off and 9200 public, anyone can:

  • list and download every index with /_cat/indices and /_search;
  • delete indices, which ransom bots do after copying them;
  • change cluster settings or fill the disk.

Check yours

sudo ss -tlnp | grep -E "9200|9300"
grep -E "^(network.host|http.host|xpack.security.enabled)" /etc/elasticsearch/elasticsearch.yml

From another machine:

curl -s http://YOUR_SERVER_IP:9200/_cat/indices

A list of indices without a password prompt means it is public and open. A 401 means security is on, but the port should still not be public.

Fix it

In /etc/elasticsearch/elasticsearch.yml, keep the API on localhost (or a private address for a cluster) and security on:

network.host: 127.0.0.1
xpack.security.enabled: true
sudo systemctl restart elasticsearch
sudo /usr/share/elasticsearch/bin/elasticsearch-reset-password -u elastic

Give your app its own user with a role limited to its indices. For OpenSearch, keep the security plugin enabled and the same bind rules.

For Docker, publish on loopback:

services:
  elasticsearch:
    image: docker.elastic.co/elasticsearch/elasticsearch:8.15.0
    environment:
      - discovery.type=single-node
      - ELASTIC_PASSWORD=${ELASTIC_PASSWORD}
    ports:
      - "127.0.0.1:9200:9200"

If you need remote access

Reach Kibana or the API through an SSH tunnel, ssh -L 9200:127.0.0.1:9200 you@YOUR_SERVER_IP, or a VPN. For a multi-node cluster, bind 9200 and 9300 to the private network only.

Common mistakes

  • xpack.security.enabled: false copied from a Docker example into a server that is on the internet.
  • Protecting 9200 but not Kibana on 5601, which has its own login only when security is on.
  • Publishing 9300. It lets another node join your cluster.

FAQ

Is a 401 response enough? It stops anonymous access, but passwords can be guessed and new bugs appear. Keep the port private too.

My indices disappeared and there is a new index asking for payment. Restore from a snapshot, rotate the passwords, and close the port before you reload data.

How do I get warned? PortGate's Server Guard alerts when 9200 or 9300 listens on a public address, including through Docker.