# Unable to connet to localhost:9200

**URL:** <https://discuss.elastic.co/t/unable-to-connet-to-localhost-9200/299945>\
**Category:** Elasticsearch\
**Created:** [March 17, 2022, 11:56am UTC](https://discuss.elastic.co/t/unable-to-connet-to-localhost-9200/299945 "2022-03-17T11:56:52Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![shamir](https://avatars.discourse-cdn.com/v4/letter/s/c57346/32.png) [@shamir](https://discuss.elastic.co/u/shamir)\
**Post date:** [March 17, 2022, 11:56am UTC](https://discuss.elastic.co/t/unable-to-connet-to-localhost-9200/299945/1 "2022-03-17T11:56:52Z")

</div>

![image](https://us1.discourse-cdn.com/elastic/original/3X/3/6/365faaff1da4608a19d9f4a2cd90b6af1bab0d81.png)  
in terminal it shows Elasticsearch status as active and running

![image](https://us1.discourse-cdn.com/elastic/original/3X/e/d/ed897cefb1a7741bb383acfe575b74d66ee6f40f.png)  
when i try to run this command it returning empty

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [March 17, 2022, 12:21pm UTC](https://discuss.elastic.co/t/unable-to-connet-to-localhost-9200/299945/2 "2022-03-17T12:21:48Z")

</div>

Welcome!

Please don't post images of text as they are hard to read, may not display correctly for everyone, and are not searchable.

Instead, paste the text and format it with `</>` icon or pairs of triple backticks (```), and check the preview window to make sure it's properly formatted before posting it. This makes it more likely that your question will receive a useful answer.

It would be great if you could update your post to solve this.

That said, if you are using a 8.x version, you should try https instead with the `--insecure` option.

If you are not, please share the full logs of Elasticsearch.

---

<div class="post-metadata">

**Author:** ![shamir](https://avatars.discourse-cdn.com/v4/letter/s/c57346/32.png) [@shamir](https://discuss.elastic.co/u/shamir)\
**Post date:** [March 17, 2022, 12:38pm UTC](https://discuss.elastic.co/t/unable-to-connet-to-localhost-9200/299945/3 "2022-03-17T12:38:08Z")

</div>

hai @dadoonet  
I'm using 7.x version

```auto
[2022-03-17T17:38:46,629][INFO][o.e.e.NodeEnvironment] [shamir-Mi-NoteBook-14] using [1] data paths, mounts [[/ (/dev/sda2)]], net usable_space [59.7gb], net total_space [233.2gb], types [ext4]
[2022-03-17T17:38:46,629][INFO][o.e.e.NodeEnvironment] [shamir-Mi-NoteBook-14] heap size [3.8gb], compressed ordinary object pointers [true]
[2022-03-17T17:38:46,699][INFO][o.e.n.Node] [shamir-Mi-NoteBook-14] node name [shamir-Mi-NoteBook-14], node ID [bbmNV2bDSO-CrfAyrAIRLg], cluster name [elasticsearch], roles [ingest, data_frozen, ml, data_hot, transform, data_content, data_warm, master, remote_cluster_client, data, data_cold]
[2022-03-17T17:38:54,273][INFO][o.e.x.m.p.l.CppLogMessageHandler] [shamir-Mi-NoteBook-14] [controller/1893] [Main.cc@123] controller (64 bit): Version 8.1.0 (Build 36e2300340f08a) Copyright (c) 2022 Elasticsearch BV
[2022-03-17T17:38:54,426][INFO][o.e.x.s.Security] [shamir-Mi-NoteBook-14] Security is enabled
[2022-03-17T17:38:54,638][INFO][o.e.x.s.a.Realms] [shamir-Mi-NoteBook-14] license mode is [trial], currently licensed security realms are [reserved/reserved,file/default_file,native/default_native]
[2022-03-17T17:38:54,647][INFO][o.e.x.s.a.s.FileRolesStore] [shamir-Mi-NoteBook-14] parsed [0] roles from file [/etc/elasticsearch/roles.yml]
[2022-03-17T17:38:55,016][INFO][o.e.x.s.InitialNodeSecurityAutoConfiguration] [shamir-Mi-NoteBook-14] Auto-configuration will not generate a password for the elastic built-in superuser, as we cannot determine if there is a terminal attached to the elasticsearch process. You can use the `bin/elasticsearch-reset-password` tool to set the password for the elastic user.
[2022-03-17T17:38:56,199][INFO][o.e.t.n.NettyAllocator] [shamir-Mi-NoteBook-14] creating NettyAllocator with the following configs: [name=elasticsearch_configured, chunk_size=1mb, suggested_max_allocation_size=1mb, factors={es.unsafe.use_netty_default_chunk_and_page_size=false, g1gc_enabled=true, g1gc_region_size=4mb}]
[2022-03-17T17:38:56,223][INFO][o.e.i.r.RecoverySettings] [shamir-Mi-NoteBook-14] using rate limit [40mb] with [default=40mb, read=0b, write=0b, max=0b]
[2022-03-17T17:38:56,254][INFO][o.e.d.DiscoveryModule] [shamir-Mi-NoteBook-14] using discovery type [multi-node] and seed hosts providers [settings]
[2022-03-17T17:38:57,159][INFO][o.e.n.Node] [shamir-Mi-NoteBook-14] initialized
[2022-03-17T17:38:57,160][INFO][o.e.n.Node] [shamir-Mi-NoteBook-14] starting ...
[2022-03-17T17:38:57,183][INFO][o.e.x.s.c.f.PersistentCache] [shamir-Mi-NoteBook-14] persistent cache index loaded
[2022-03-17T17:38:57,184][INFO][o.e.x.d.l.DeprecationIndexingComponent] [shamir-Mi-NoteBook-14] deprecation component started
[2022-03-17T17:38:57,302][INFO][o.e.t.TransportService] [shamir-Mi-NoteBook-14] publish_address {localhost/127.0.0.1:9300}, bound_addresses {127.0.0.1:9300}
[2022-03-17T17:38:57,621][INFO][o.e.c.c.Coordinator] [shamir-Mi-NoteBook-14] cluster UUID [kE7sxK_iQcaF2hM832yOXQ]
[2022-03-17T17:38:57,885][INFO][o.e.c.s.MasterService] [shamir-Mi-NoteBook-14] elected-as-master ([1] nodes joined)[{shamir-Mi-NoteBook-14}{bbmNV2bDSO-CrfAyrAIRLg}{S2oucpo4T1-8lZ29ES7WTg}{localhost}{127.0.0.1:9300}{cdfhilmrstw} completing election, _BECOME_MASTER_TASK_, _FINISH_ELECTION_], term: 2, version: 56, delta: master node changed {previous [], current [{shamir-Mi-NoteBook-14}{bbmNV2bDSO-CrfAyrAIRLg}{S2oucpo4T1-8lZ29ES7WTg}{localhost}{127.0.0.1:9300}{cdfhilmrstw}]}
[2022-03-17T17:38:57,979][INFO][o.e.c.s.ClusterApplierService] [shamir-Mi-NoteBook-14] master node changed {previous [], current [{shamir-Mi-NoteBook-14}{bbmNV2bDSO-CrfAyrAIRLg}{S2oucpo4T1-8lZ29ES7WTg}{localhost}{127.0.0.1:9300}{cdfhilmrstw}]}, term: 2, version: 56, reason: Publication{term=2, version=56}
[2022-03-17T17:38:58,031][INFO][o.e.h.AbstractHttpServerTransport] [shamir-Mi-NoteBook-14] publish_address {192.168.0.106:9200}, bound_addresses {[::1]:9200}, {127.0.0.1:9200}, {192.168.0.106:9200}
[2022-03-17T17:38:58,032][INFO][o.e.n.Node] [shamir-Mi-NoteBook-14] started
[2022-03-17T17:38:58,130][INFO][o.e.l.LicenseService] [shamir-Mi-NoteBook-14] license [64da8fd7-880c-4f47-b18b-ae76f56194a3] mode [basic] - valid
[2022-03-17T17:38:58,132][INFO][o.e.x.s.a.Realms] [shamir-Mi-NoteBook-14] license mode is [basic], currently licensed security realms are [reserved/reserved,file/default_file,native/default_native]
[2022-03-17T17:38:58,139][INFO][o.e.g.GatewayService] [shamir-Mi-NoteBook-14] recovered [1] indices into cluster_state
[2022-03-17T17:38:58,530][INFO][o.e.c.r.a.AllocationService] [shamir-Mi-NoteBook-14] current.health="GREEN" message="Cluster health status changed from [RED] to [GREEN] (reason: [shards started [[.geoip_databases][0]]])." previous.health="RED" reason="shards started [[.geoip_databases][0]]"
[2022-03-17T17:38:58,852][INFO][o.e.i.g.DatabaseNodeService] [shamir-Mi-NoteBook-14] successfully loaded geoip database file [GeoLite2-Country.mmdb]
[2022-03-17T17:38:58,878][INFO][o.e.i.g.DatabaseNodeService] [shamir-Mi-NoteBook-14] successfully loaded geoip database file [GeoLite2-ASN.mmdb]
[2022-03-17T17:38:59,689][INFO][o.e.i.g.DatabaseNodeService] [shamir-Mi-NoteBook-14] successfully loaded geoip database file [GeoLite2-City.mmdb]
[2022-03-17T17:40:33,286][WARN][o.e.x.s.t.n.SecurityNetty4HttpServerTransport] [shamir-Mi-NoteBook-14] received plaintext http traffic on an https channel, closing connection

```

---

<div class="post-metadata">

**Author:** ![ikakavas](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ikakavas/32/34430_2.png) [@ikakavas](https://discuss.elastic.co/u/ikakavas)\
**Post date:** [March 17, 2022, 12:50pm UTC](https://discuss.elastic.co/t/unable-to-connet-to-localhost-9200/299945/4 "2022-03-17T12:50:09Z")

</div>

> [2022-03-17T17:40:33,286][WARN][o.e.x.s.t.n.SecurityNetty4HttpServerTransport] [shamir-Mi-NoteBook-14] received plaintext http traffic on an https channel, closing connection

Your cluster is setup with TLS enabled. So you need to access it over https, not http. Try

```auto
curl -X GET https://localhost:9200

```

> [@dadoonet](#):
>
> That said, if you are using a 8.x version, you should try https instead with the `--insecure` option.

FWIW, there is no need to use `-k` or `--insecure` when accessing a self-configured 8.x cluster. The HTTP CA cert is available at a specific location, you can use `--cacert config/certs/http_ca.crt` with curl.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [March 17, 2022, 1:50pm UTC](https://discuss.elastic.co/t/unable-to-connet-to-localhost-9200/299945/5 "2022-03-17T13:50:54Z")

</div>

Ha! Thanks @ikakavas. That's indeed better and safer. 😉

---

<div class="post-metadata">

**Author:** ![shamir](https://avatars.discourse-cdn.com/v4/letter/s/c57346/32.png) [@shamir](https://discuss.elastic.co/u/shamir)\
**Post date:** [March 17, 2022, 4:15pm UTC](https://discuss.elastic.co/t/unable-to-connet-to-localhost-9200/299945/6 "2022-03-17T16:15:04Z")

</div>

thanks @ikakavas and @dadoonet

```auto
{"error":{"root_cause":[{"type":"security_exception","reason":"missing authentication credentials for REST request [/]","header":{"WWW-Authenticate":["Basic realm=\"security\" charset=\"UTF-8\"","Bearer realm=\"security\"","ApiKey"]}}],"type":"security_exception","reason":"missing authentication credentials for REST request [/]","header":{"WWW-Authenticate":["Basic realm=\"security\" charset=\"UTF-8\"","Bearer realm=\"security\"","ApiKey"]}},"status":401}

```

how do i add authentication here?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [March 17, 2022, 7:13pm UTC](https://discuss.elastic.co/t/unable-to-connet-to-localhost-9200/299945/7 "2022-03-17T19:13:33Z")

</div>

```
curl -u elastic ....
```

---

<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:** [April 14, 2022, 7:14pm UTC](https://discuss.elastic.co/t/unable-to-connet-to-localhost-9200/299945/8 "2022-04-14T19:14:31Z")

</div>

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