# Elasticsearch 2.0 and Vagrant port forwarding

**URL:** <https://discuss.elastic.co/t/elasticsearch-2-0-and-vagrant-port-forwarding/31851>\
**Category:** Elasticsearch\
**Created:** [October 8, 2015, 2:13pm UTC](https://discuss.elastic.co/t/elasticsearch-2-0-and-vagrant-port-forwarding/31851 "2015-10-08T14:13:36Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![softwaredoug](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/softwaredoug/32/22681_2.png) [@softwaredoug](https://discuss.elastic.co/u/softwaredoug)\
**Post date:** [October 8, 2015, 2:13pm UTC](https://discuss.elastic.co/t/elasticsearch-2-0-and-vagrant-port-forwarding/31851/1 "2015-10-08T14:13:36Z")

</div>

Hi all,

I'm having a heck of a time updating a [vagrant box](https://github.com/o19s/elasticsearch-vagrant/tree/es2) we use for local Elasticsearch experimentation.

The vagrant box is rather simple, its Ubuntu 14.04 based and it

- Installs OpenJDK
- Downloads and installs the Elasticsearch 2.0 deb
- Runs the Elasticsearch service
- Has a port forward for 9200 to localhost

```auto
  config.vm.network "forwarded_port", guest: 9200, host: 9201

```

Yet curling from the host I get

```auto
curl -XGET http://localhost:9201
curl: (56) Recv failure: Connection reset by peer

```

I know one change with Elasticsearch 2 is that it binds to localhost by default. Yet I fail to see how this would prevent ssh port forwarding to work. My Elasticsearch 1.5 Vagrant box is happy to be fwd'd too:

```auto
doug@76:~/workspace/elasticsearch-vagrant$ curl -XGET http://localhost:9200
{
  "status" : 200,
  "name" : "Gin Genie",
  "cluster_name" : "elasticsearch",
  "version" : {
    "number" : "1.5.2",
    "build_hash" : "62ff9868b4c8a0c45860bebb259e21980778ab1c",
    "build_timestamp" : "2015-04-27T09:21:06Z",
    "build_snapshot" : false,
    "lucene_version" : "4.10.4"
  },
  "tagline" : "You Know, for Search"
}

```

I must be doing something stupid...

---

<div class="post-metadata">

**Author:** ![nik9000](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nik9000/32/44947_2.png) [@nik9000](https://discuss.elastic.co/u/nik9000)\
**Post date:** [October 8, 2015, 2:39pm UTC](https://discuss.elastic.co/t/elasticsearch-2-0-and-vagrant-port-forwarding/31851/2 "2015-10-08T14:39:32Z")

</div>

> [@softwaredoug](#):
>
> I know one change with Elasticsearch 2 is that it binds to localhost by default.

I suspect this is it. From the VM's perspective the request is coming in through its network port. Trying binding to `_non_loopback_` and see if that works.

---

<div class="post-metadata">

**Author:** ![softwaredoug](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/softwaredoug/32/22681_2.png) [@softwaredoug](https://discuss.elastic.co/u/softwaredoug)\
**Post date:** [October 8, 2015, 2:44pm UTC](https://discuss.elastic.co/t/elasticsearch-2-0-and-vagrant-port-forwarding/31851/3 "2015-10-08T14:44:53Z")

</div>

Thanks!

It does work as it binds to an external facing address. Though my understanding of `forwarded_port` was it does an ssh port fwd. Is that not the case? I usually don't use this setup (I prefer a private network for my vagrant boxes), so I may have extra dumbs here.

---

<div class="post-metadata">

**Author:** ![nik9000](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nik9000/32/44947_2.png) [@nik9000](https://discuss.elastic.co/u/nik9000)\
**Post date:** [October 8, 2015, 3:00pm UTC](https://discuss.elastic.co/t/elasticsearch-2-0-and-vagrant-port-forwarding/31851/4 "2015-10-08T15:00:51Z")

</div>

> [@softwaredoug](#):
>
> Though my understanding of forwarded\_port was it does an ssh port fwd.

I _think_ it does it uses Virtualbox configuration because for port forwarding changes to take effect you have to reload the box. My instinct is that virtualbox implements this by making connections to the host's port come in to the guest's public network. I think this because when I `vagrant ssh` into a box it'll tell me:

```auto
Last login: Wed Oct 7 20:20:07 2015 from 10.0.2.2

```

rather than

```auto
Last login: Wed Oct 7 20:20:07 2015 from 127.0.0.1

```

---

<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:** [July 5, 2017, 11:45pm UTC](https://discuss.elastic.co/t/elasticsearch-2-0-and-vagrant-port-forwarding/31851/5 "2017-07-05T23:45:51Z")

</div>


