# Error loading yaml file-did not find expected key

**URL:** <https://discuss.elastic.co/t/error-loading-yaml-file-did-not-find-expected-key/248554>\
**Category:** Beats\
**Tags:** filebeat\
**Created:** [September 14, 2020, 3:54pm UTC](https://discuss.elastic.co/t/error-loading-yaml-file-did-not-find-expected-key/248554 "2020-09-14T15:54:23Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![vsekvsek](https://avatars.discourse-cdn.com/v4/letter/v/a8b319/32.png) [@vsekvsek](https://discuss.elastic.co/u/vsekvsek)\
**Post date:** [September 14, 2020, 3:54pm UTC](https://discuss.elastic.co/t/error-loading-yaml-file-did-not-find-expected-key/248554/1 "2020-09-14T15:54:24Z")

</div>

.\filebeat.exe modules enable apache  
Error initializing beat: error loading config file: yaml line 70: did not find expected key

This is on line 70 on the filebeat file.

```auto
path: "C:\\Program Files\\filebeat\\module\\apache\\apache.yml"

```

The file and path all exist. I have triple/quadruple checked them. What gives?

---

<div class="post-metadata">

**Author:** ![shaunak](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shaunak/32/6643_2.png) [@shaunak](https://discuss.elastic.co/u/shaunak)\
**Post date:** [September 14, 2020, 8:59pm UTC](https://discuss.elastic.co/t/error-loading-yaml-file-did-not-find-expected-key/248554/2 "2020-09-14T20:59:46Z")

</div>

Hi @vsekvsek, welcome to the Elastic Community forums!

YAML parsing can be finicky, sometimes due to whitespace issues. Could you use [https://gist.github.com/](https://gist.github.com/) or [https://pastebin.com/](https://pastebin.com/) to paste your **entire** Filebeat configuration file and separately also the **entire** `C:\\Program Files\\filebeat\\module\\apache\\apache.yml`file, and then post the two links here please?

Thanks,

Shaunak

---

<div class="post-metadata">

**Author:** ![vsekvsek](https://avatars.discourse-cdn.com/v4/letter/v/a8b319/32.png) [@vsekvsek](https://discuss.elastic.co/u/vsekvsek)\
**Post date:** [September 15, 2020, 3:24pm UTC](https://discuss.elastic.co/t/error-loading-yaml-file-did-not-find-expected-key/248554/3 "2020-09-15T15:24:10Z")

</div>

hopefully this link works

> **[\###################### Filebeat Configuration Example...](https://pastebin.com/2A9c7xpr)**
>
> Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.

---

<div class="post-metadata">

**Author:** ![shaunak](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shaunak/32/6643_2.png) [@shaunak](https://discuss.elastic.co/u/shaunak)\
**Post date:** [September 15, 2020, 3:53pm UTC](https://discuss.elastic.co/t/error-loading-yaml-file-did-not-find-expected-key/248554/4 "2020-09-15T15:53:37Z")

</div>

Thanks,

I see that there are 3 spaces before `path` (on line 69 in pastebin). Everywhere else I see that fields at that level have 2 spaces before them. Can you try removing 1 space before `path` and see if that helps?

Shaunak

---

<div class="post-metadata">

**Author:** ![vsekvsek](https://avatars.discourse-cdn.com/v4/letter/v/a8b319/32.png) [@vsekvsek](https://discuss.elastic.co/u/vsekvsek)\
**Post date:** [September 15, 2020, 8:40pm UTC](https://discuss.elastic.co/t/error-loading-yaml-file-did-not-find-expected-key/248554/5 "2020-09-15T20:40:05Z")

</div>

That fixed that issue thanks. I now get this error when trying to start it up.  
PS C:\Program Files\filebeat\> .\filebeat.exe setup Start-Service filebeat  
Exiting: couldn't connect to any of the configured Elasticsearch hosts. Errors: [error connecting to Elasticsearch at [http://localhost:5601](http://localhost:5601): Failed to parse JSON response: invalid character '\<' looking for beginning of value]  
PS C:\Program Files\filebeat\>

here is a link to my current yml file. Can you see what I am missing?

> **[\###################### Filebeat Configuration Example...](https://pastebin.com/KtxKTdxC)**
>
> Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.

---

<div class="post-metadata">

**Author:** ![shaunak](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shaunak/32/6643_2.png) [@shaunak](https://discuss.elastic.co/u/shaunak)\
**Post date:** [September 16, 2020, 9:48am UTC](https://discuss.elastic.co/t/error-loading-yaml-file-did-not-find-expected-key/248554/6 "2020-09-16T09:48:36Z")

</div>

Line 155:

```auto
  hosts: ["localhost:5601"]

```

This should almost certainly be:

```auto
  hosts: ["localhost:9200"]

```

The first Elasticsearch node in a cluster starts listening on port 9200 by default. Kibana starts listening on port 5601 by default but since this line pertains to the Elasticsearch output, you want to the port to be the one that Elasticsearch is listening on.

---

<div class="post-metadata">

**Author:** ![vsekvsek](https://avatars.discourse-cdn.com/v4/letter/v/a8b319/32.png) [@vsekvsek](https://discuss.elastic.co/u/vsekvsek)\
**Post date:** [September 16, 2020, 1:48pm UTC](https://discuss.elastic.co/t/error-loading-yaml-file-did-not-find-expected-key/248554/7 "2020-09-16T13:48:45Z")

</div>

Thanks, made that change at line 155 and get past that but get this error next. I must be missing a json file or maybe its malformed? Also those log files its trying to rotate dont exist. Not sure if I need to turn on/off a setting somewhere?

PS C:\Program Files\filebeat\> .\filebeat.exe setup Start-Service filebeat  
2020-09-16 06:31:56.5647872 -0700 PDT m=+0.350059001 write error: failed to rotate backups: failed to rotate backups: rename C:\Program Files\filebeat\logs\filebeat.7 C:\Program Files\filebeat\logs\filebeat.8: Access is denied.  
2020-09-16 06:31:57.6993527 -0700 PDT m=+1.484624501 write error: failed to rotate backups: failed to rotate backups: rename C:\Program Files\filebeat\logs\filebeat.7 C:\Program Files\filebeat\logs\filebeat.8: Access is denied.  
Exiting: couldn't connect to any of the configured Elasticsearch hosts. Errors: [error connecting to Elasticsearch at [http://localhost:5601](http://localhost:5601): Failed to parse JSON response: invalid character '\<' looking for beginning of value]

---

<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:** [October 14, 2020, 3:48pm UTC](https://discuss.elastic.co/t/error-loading-yaml-file-did-not-find-expected-key/248554/8 "2020-10-14T15:48:45Z")

</div>

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