简体   繁体   中英

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM