# Prefix and port appear flipped in es-hadoop implementation

**URL:** https://discuss.elastic.co/t/prefix-and-port-appear-flipped-in-es-hadoop-implementation/328072
**Category:** Elasticsearch
**Tags:** es-hadoop
**Created:** [March 20, 2023, 12:22pm UTC](https://discuss.elastic.co/t/prefix-and-port-appear-flipped-in-es-hadoop-implementation/328072 "2023-03-20T12:22:56Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![petersedivec](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/petersedivec/32/81934_2.png) [@petersedivec](https://discuss.elastic.co/u/petersedivec)
#### Post date: [March 20, 2023, 12:22pm UTC](https://discuss.elastic.co/t/prefix-and-port-appear-flipped-in-es-hadoop-implementation/328072/1 "2023-03-20T12:22:57Z")

</div>

Attempting to read/write with es-hadoop however I am getting the following error in Databricks

```auto
EsHadoopInvalidRequest: [HEAD] on [index_name] failed; server [https://serveraddress.com/es:443] returned [405|Method Not Allowed:]

```

Note the port comes after the prefix which contradicts what the [documentation](https://www.elastic.co/guide/en/elasticsearch/hadoop/current/configuration.html) says here for prefix

`es.nodes.path.prefix` (default empty)  
Prefix to add to _all_ requests made to Elasticsearch. Useful in environments where the cluster is proxied/routed under a certain path. For example, if the cluster is located at `someaddress:someport/custom/path/prefix`, one would set `es.nodes.path.prefix` to `/custom/path/prefix`

My config in databricks just looks like

```auto
spark.read.format("org.elasticsearch.spark.sql")
    .option("es.nodes", es_url)
    .option("es.nodes.wan.only","true")
    .option("es.nodes.path.prefix", "/es")
    .option("es.port", "443")

```

From the databricks terminal if I attempt to curl using

```auto
curl https://serveraddress.com:443/es/_search

```

I get the expected response, however if I flip it and

```auto
curl https://serveraddress.com/es:443/_search

```

It fails with the same error. This also works successfully

```auto
curl https://serveraddress.com/es/_search

```

so if there is a way to completely omit the port that would be great but it seems like this defaults to 9200 and I haven't figured out how to prevent that.

Any suggestions would be appreciated? Is this a bug that warrants an issue on the GH project?

---

<div class="post-metadata">

### Author: ![leandrojmp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/leandrojmp/32/107231_2.png) [@leandrojmp](https://discuss.elastic.co/u/leandrojmp)
#### Post date: [March 20, 2023, 12:45pm UTC](https://discuss.elastic.co/t/prefix-and-port-appear-flipped-in-es-hadoop-implementation/328072/2 "2023-03-20T12:45:20Z")

</div>

> [@petersedivec](#):
>
> Any suggestions would be appreciated? Is this a bug that warrants an issue on the GH project?

This is weird and it looks like a bug, maybe it is better to open an Github issue with instructions to reproduce this bug.

But in the mean time you can ignore the `es.port` and pass the port directly in the node url, something like `serveraddress.com:443`.

---

<div class="post-metadata">

### Author: ![petersedivec](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/petersedivec/32/81934_2.png) [@petersedivec](https://discuss.elastic.co/u/petersedivec)
#### Post date: [March 20, 2023, 1:43pm UTC](https://discuss.elastic.co/t/prefix-and-port-appear-flipped-in-es-hadoop-implementation/328072/3 "2023-03-20T13:43:09Z")

</div>

Awesome, that works regarding passing the port in the URL. I'm kicking myself for not thinking to have attempted that. Will open a github issue with steps to reproduce

---

<div class="post-metadata">

### Author: ![Keith\_Massey](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/keith_massey/32/83666_2.png) [@Keith\_Massey](https://discuss.elastic.co/u/Keith_Massey)
#### Post date: [March 20, 2023, 3:01pm UTC](https://discuss.elastic.co/t/prefix-and-port-appear-flipped-in-es-hadoop-implementation/328072/4 "2023-03-20T15:01:51Z")

</div>

After a brief look at the code, I'm not sure how this happens -- it appears to correctly add the prefix after the port. Steps to reproduce in a ticket will be great. Thanks.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [April 17, 2023, 3:02pm UTC](https://discuss.elastic.co/t/prefix-and-port-appear-flipped-in-es-hadoop-implementation/328072/5 "2023-04-17T15:02:08Z")

</div>

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