<p>I am trying to connect my elastic search pod, to ports 9200 and 9300. When I go to:</p>

<p><code>http://localhost:$IP_FROM_KUBECTL_PROXY(usually 8001)/api/v1/namespaces/default/pods/$POD_NAME/proxy/</code></p>

<p>I see the following error:</p>

<pre><code>Error: 'net/http: HTTP/1.x transport connection broken: malformed HTTP status code "is"'
Trying to reach: 'http://172.17.0.5:9300/'
</code></pre>

<p>What I did is, running :</p>

<pre><code>kubectl run elasticsearch --image=elasticsearch:6.6.1 -labels="elasticsearch" --env="discovery.type=single-node" --port=9200 --port=9300
</code></pre>

<p>and running the following service:</p>

<pre><code>kind: Service
apiVersion: v1
metadata:
  name: elasticsearch
spec:
  selector:
    host: elasticsearch
    subdomain: for-kibana
    app: elasticsearch
  ports:
  - protocol: TCP
    name: serving
    port: 9200
    targetPort: 9200
  - protocol: TCP
    name: node2node
    port: 9300
    targetPort: 9300
</code></pre>

<p>It's weird, because when I just use port 9200, all works, but when I run with 9300, its fail.</p>

<p>Port 9300 is binary protocol (not http) and used for node communication. Only port 9200 exposed the Rest Api</p>

<p>From the <a href="https://www.elastic.co/guide/en/elasticsearch/guide/current/_talking_to_elasticsearch.html" rel="nofollow noreferrer">documentation</a>:</p>

<blockquote>
  <p>Both Java clients talk to the cluster over port 9300, using the native
  Elasticsearch transport protocol. The nodes in the cluster also
  communicate with each other over port 9300. If this port is not open,
  your nodes will not be able to form a cluster.</p>
</blockquote>
