# Failed to connect to localhost port 9200: Connection refused

**URL:** <https://discuss.elastic.co/t/failed-to-connect-to-localhost-port-9200-connection-refused/312954>\
**Category:** Elasticsearch\
**Tags:** docker\
**Created:** [August 25, 2022, 5:45pm UTC](https://discuss.elastic.co/t/failed-to-connect-to-localhost-port-9200-connection-refused/312954 "2022-08-25T17:45:56Z")\
**Posts on this page:** 1\
**Showing post:** 10

<div class="post-metadata">

**Author:** ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)\
**Post date:** [August 30, 2022, 11:04pm UTC](https://discuss.elastic.co/t/failed-to-connect-to-localhost-port-9200-connection-refused/312954/10 "2022-08-30T23:04:35Z")

</div>

Ohh I say / realized this

```auto
[2022-08-26T20:28:32,283][ERROR][o.e.b.Elasticsearch] [loganalysisclass1.novalocal] fatal exception while booting Elasticsearch
java.nio.file.AccessDeniedException: /var/run/elasticsearch

```

Exact how did you install elasticsearch using what method and did you change any file permissions

See this thread

> [@Unable to start elasticsearch as service](https://discuss.elastic.co/t/unable-to-start-elasticsearch-as-service/178440/6):
>
> Hi @Kajol_Nimesh, Access denied exception is showing for the path /var/lib/elasticsearch. could you please check the access permission for this path. If you see below error it clearly show that not writable and multiple nodes were started. Please check and let me know if you still facing any issue. Regards, Harsh Bajaj

This is how my permissions look for

`/var/run/elasticsearch`

```auto
drwxr-xr-x 2 elasticsearch elasticsearch 60 Aug 22 16:54 elasticsearch

```

so perhaps you need

`sudo chown -R elasticsearch:elasticsearch /var/run/elasticsearch`

---

_[View the full topic](https://discuss.elastic.co/t/failed-to-connect-to-localhost-port-9200-connection-refused/312954)._
