Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Elasticsearch curl: (7) couldn't connect to host

I was trying out elastic search with mongodb.

I have followed steps from http://satishgandham.com/2012/09/a-complete-guide-to-integrating-mongodb-with-elastic-search/

But when I try to set index by

curl -XPUT 'http://localhost:9200/_river/mongodb/_meta' -d '
{
    "type": "mongodb",
    "mongodb": {
        "db": "smmc-dart",
        "collection": "smmc_collectionDetails"
    },
    "index": {
        "name": "caseName",
        "type": "string"
    }
}'

I'm getting error

curl: (7) couldn't connect to host

When I tried http://localhost:9200/ on my browser it shows

{
  "status" : 200,
  "name" : "Nicholas Scratch",
  "version" : {
    "number" : "1.1.0",
    "build_hash" : "2181e113dea80b4a9e31e58e9686658a2d46e363",
    "build_timestamp" : "2014-03-25T15:59:51Z",
    "build_snapshot" : false,
    "lucene_version" : "4.7"
  },
  "tagline" : "You Know, for Search"
}

I also tried this in terminal

curl -XGET http://10.20.4.220:9200/

It resulted

curl: (7) couldn't connect to host

Why is this happening and how to fix it.

like image 832
Okky Avatar asked Apr 17 '14 10:04

Okky


1 Answers

On my Mac OS X, I use 127.0.0.1:9200/ instead of http://localhost:9200/ cause I had the same problem.

I think that when you use the command the terminal replaces the localhost by it's IPv6 address and I'm not sure that curl supports that.

Please check and let me know.

like image 113
eliasah Avatar answered Oct 17 '22 10:10

eliasah