Elasticsearch 2.0 and Vagrant port forwarding

Hi all,

I'm having a heck of a time updating a vagrant box 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
  config.vm.network "forwarded_port", guest: 9200, host: 9201

Yet curling from the host I get

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:

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...

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.

2 Likes

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.

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:

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

rather than

Last login: Wed Oct  7 20:20:07 2015 from 127.0.0.1
1 Like