Curl: (7) failed to connect to localhost port 9200: connection refused using curl -X PUT "localhost:9200"

Need help guys! please

I add mappings on Elasticsearch using this command line

curl -X PUT "localhost:9200/newsout/_mapping/test-type" -H 'Content-Type: application/json' -d' {
"properties": {
"author": { "type": "string" },
"date": {
"type": "date",
"format": "yyyy-MM-dd"
},
"description": {
"type": "string",
"analyzer": "french"
},
"topics": { "type": "string" },
"link": { "type": "string", "index": "not_analyzed" },
"locations": { "type": "string" },
"organizations": { "type": "string" },
"persons": { "type": "string" },
"text": {
"type": "string",
"analyzer": "french"
},
"title": {
"type": "string",
"analyzer": "french"
}
}
}'

it appears that this error occurs

curl: (7) failed to connect to localhost port 9200: connection refused

you have to notice that this errors happens when I upgraded Elasticsearch from (alpine-elasticsearch ---->Elasticsearch v 6.0.0)

Sounds like the service is not running or that there is a network blocker somewhere.

When i return to old version Using alpine-Elasticsearch image on docker compose (i think it is 2.2.1 version)everything seems to work.the erronés happent only when i tap curl -X Put to create a mapping for my index.

Can i provide to you my docker compose if it is needed ?

What are elasticsearch logs?

elasticsearch_1 | [2019-04-09T06:50:19,089][INFO ][o.e.n.Node ] initializing ...
elasticsearch_1 | [2019-04-09T06:50:19,281][INFO ][o.e.e.NodeEnvironment ] [jSjxvbp] using [1] data paths, mounts [[/usr/share/elasticsearch/data (/dev/dm-0)]], net usable_space [20.6gb], net total_space [47.9gb], types [ext4]
elasticsearch_1 | [2019-04-09T06:50:19,282][INFO ][o.e.e.NodeEnvironment ] [jSjxvbp] heap size [1007.3mb], compressed ordinary object pointers [true]
elasticsearch_1 | [2019-04-09T06:50:19,286][INFO ][o.e.n.Node ] node name [jSjxvbp] derived from node ID [jSjxvbpOSXicUUeDO_W8mw]; set [node.name] to override
elasticsearch_1 | [2019-04-09T06:50:19,289][INFO ][o.e.n.Node ] version[6.0.0], pid[1], build[8f0685b/2017-11-10T18:41:22.859Z], OS[Linux/3.16.0-4-amd64/amd64], JVM[Oracle Corporation/OpenJDK 64-Bit Server VM/1.8.0_151/25.151-b12]
elasticsearch_1 | [2019-04-09T06:50:19,289][INFO ][o.e.n.Node ] JVM arguments [-Xms1g, -Xmx1g, -XX:+UseConcMarkSweepGC, -XX:CMSInitiatingOccupancyFraction=75, -XX:+UseCMSInitiatingOccupancyOnly, -XX:+AlwaysPreTouch, -Xss1m, -Djava.awt.headless=true, -Dfile.encoding=UTF-8, -Djna.nosys=true, -XX:-OmitStackTraceInFastThrow, -Dio.netty.noUnsafe=true, -Dio.netty.noKeySetOptimization=true, -Dio.netty.recycler.maxCapacityPerThread=0, -Dlog4j.shutdownHookEnabled=false, -Dlog4j2.disable.jmx=true, -XX:+HeapDumpOnOutOfMemoryError, -Des.cgroups.hierarchy.override=/, -Des.path.home=/usr/share/elasticsearch, -Des.path.conf=/usr/share/elasticsearch/config]
elasticsearch_1 | [2019-04-09T06:50:22,906][INFO ][o.e.p.PluginsService ] [jSjxvbp] loaded module [aggs-matrix-stats]
elasticsearch_1 | [2019-04-09T06:50:22,912][INFO ][o.e.p.PluginsService ] [jSjxvbp] loaded module [analysis-common]
elasticsearch_1 | [2019-04-09T06:50:22,912][INFO ][o.e.p.PluginsService ] [jSjxvbp] loaded module [ingest-common]
elasticsearch_1 | [2019-04-09T06:50:22,913][INFO ][o.e.p.PluginsService ] [jSjxvbp] loaded module [lang-expression]
elasticsearch_1 | [2019-04-09T06:50:22,913][INFO ][o.e.p.PluginsService ] [jSjxvbp] loaded module [lang-mustache]
elasticsearch_1 | [2019-04-09T06:50:22,913][INFO ][o.e.p.PluginsService ] [jSjxvbp] loaded module [lang-painless]
elasticsearch_1 | [2019-04-09T06:50:22,913][INFO ][o.e.p.PluginsService ] [jSjxvbp] loaded module [parent-join]
elasticsearch_1 | [2019-04-09T06:50:22,913][INFO ][o.e.p.PluginsService ] [jSjxvbp] loaded module [percolator]
elasticsearch_1 | [2019-04-09T06:50:22,913][INFO ][o.e.p.PluginsService ] [jSjxvbp] loaded module [reindex]
elasticsearch_1 | [2019-04-09T06:50:22,913][INFO ][o.e.p.PluginsService ] [jSjxvbp] loaded module [repository-url]
elasticsearch_1 | [2019-04-09T06:50:22,913][INFO ][o.e.p.PluginsService ] [jSjxvbp] loaded module [transport-netty4]
elasticsearch_1 | [2019-04-09T06:50:22,913][INFO ][o.e.p.PluginsService ] [jSjxvbp] loaded module [tribe]
elasticsearch_1 | [2019-04-09T06:50:22,914][INFO ][o.e.p.PluginsService ] [jSjxvbp] loaded plugin [ingest-geoip]
elasticsearch_1 | [2019-04-09T06:50:22,914][INFO ][o.e.p.PluginsService ] [jSjxvbp] loaded plugin [ingest-user-agent]
elasticsearch_1 | [2019-04-09T06:50:22,914][INFO ][o.e.p.PluginsService ] [jSjxvbp] loaded plugin [x-pack]
elasticsearch_1 | [2019-04-09T06:50:29,073][INFO ][o.e.x.m.j.p.l.CppLogMessageHandler] [controller/89] [Main.cc@128] controller (64 bit): Version 6.0.0 (Build 8e6ab35cf803a2) Copyright (c) 2017 Elasticsearch BV
elasticsearch_1 | [2019-04-09T06:50:29,301][INFO ][o.e.d.DiscoveryModule ] [jSjxvbp] using discovery type [zen]
elasticsearch_1 | [2019-04-09T06:50:31,881][INFO ][o.e.n.Node ] initialized
elasticsearch_1 | [2019-04-09T06:50:31,881][INFO ][o.e.n.Node ] [jSjxvbp] starting ...
elasticsearch_1 | [2019-04-09T06:50:32,311][INFO ][o.e.t.TransportService ] [jSjxvbp] publish_address {172.18.0.3:9300}, bound_addresses {0.0.0.0:9300}
elasticsearch_1 | [2019-04-09T06:50:32,357][INFO ][o.e.b.BootstrapChecks ] [jSjxvbp] bound or publishing to a non-loopback or non-link-local address, enforcing bootstrap checks
elasticsearch_1 | ERROR: [1] bootstrap checks failed
elasticsearch_1 | [1]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
elasticsearch_1 | [2019-04-09T06:50:32,397][INFO ][o.e.n.Node ] [jSjxvbp] stopping ...
elasticsearch_1 | [2019-04-09T06:50:32,443][INFO ][o.e.n.Node ] [jSjxvbp] stopped
elasticsearch_1 | [2019-04-09T06:50:32,444][INFO ][o.e.n.Node ] [jSjxvbp] closing ...
elasticsearch_1 | [2019-04-09T06:50:32,467][INFO ][o.e.n.Node ] [jSjxvbp] closed
elasticsearch_1 | [2019-04-09T06:50:32,471][INFO ][o.e.x.m.j.p.NativeController] Native controller process has stopped - no new native processes can be started

i think my problem is related to elasticsearch_1 | [1]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144] ,so,i used this command line sysctl -w vm.max_map_count=262144 to increase virtual memory in docker_images folder .

Then i retry again to add mapping for my index ,i see this error : {"error":{"root_cause":[{"type":"mapper_parsing_exception","reason":"No handler for type [string] declared on field [author]"}],"type":"mapper_parsing_exception","reason":"No handler for type [string] declared on field [author]"},"status":400}(

Please format your code, logs or configuration files using </> icon as explained in this guide and not the citation button. It will make your post more readable.

Or use markdown style like:

```
CODE
```

This is the icon to use if you are not using markdown format:

There's a live preview panel for exactly this reasons.

Lots of people read these forums, and many of them will simply skip over a post that is difficult to read, because it's just too large an investment of their time to try and follow a wall of badly formatted text.
If your goal is to get an answer to your questions, it's in your interest to make it as easy to read and understand as possible.

Here the problem is:

Please read Bootstrap Checks | Elasticsearch Guide [8.11] | Elastic

elasticsearch_1 | ERROR: [1] bootstrap checks failed
elasticsearch_1 | [1]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

i think my problem is related to elasticsearch_1 | [1]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144] ,so,i used this command line

sysctl -w vm.max_map_count=262144 to increase virtual memory in docker_images folder

Then i retry again to add mapping for my index ,i see this error

{"error":{"root_cause":[{"type":"mapper_parsing_exception","reason":"No handler for type [string] declared on field [author]"}],"type":"mapper_parsing_exception","reason":"No handler for type [string] declared on field [author]"},"status":400}

That's another error and another problem that would deserve a new question.

Anyway, it's just because string does not exist anymore in mapping. Use text or keyword instead. If you have further question, please open a new question.

thank you

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