# Logstash Keystore not working when running logstash as a service

**URL:** <https://discuss.elastic.co/t/logstash-keystore-not-working-when-running-logstash-as-a-service/366230>\
**Category:** Logstash\
**Created:** [September 9, 2024, 8:35am UTC](https://discuss.elastic.co/t/logstash-keystore-not-working-when-running-logstash-as-a-service/366230 "2024-09-09T08:35:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Raven\_Music](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/raven_music/32/137422_2.png) [@Raven\_Music](https://discuss.elastic.co/u/Raven_Music)\
**Post date:** [September 9, 2024, 8:35am UTC](https://discuss.elastic.co/t/logstash-keystore-not-working-when-running-logstash-as-a-service/366230/1 "2024-09-09T08:35:11Z")

</div>

Hi, I'm trying to store the hosts and the logstash\_user password in a keystore in my logstash conf.d output. I have a Ubuntu 22 system. The keystore works perfectly fine with my testconfig when I run logstash like this, as root:

`sudo /usr/share/logstash/bin/logstash --path.settings /etc/logstash -f /etc/logstash/test.conf`

It also works like this:

`sudo -u logstash /usr/share/logstash/bin/logstash --path.settings /etc/logstash -f /etc/logstash/test.conf`

But when I run it as a service, I get the following error in the logstash-plain.log:

`[2024-09-09T10:21:32,077][ERROR][logstash.agent] Failed to execute action {:action=>LogStash::PipelineAction::Create/pipeline_id:xxxxxxxxxx, :exception=>"Java::OrgLogstashSecretStore::SecretStoreException::LoadException", :message=>"Found a file at /etc/logstash/logstash.keystore, but it is not a valid Logstash keystore."`

I stored my logstash keystore password in /etc/environment. I've tried creating the keystore as root and as the logstash user, both did work for running it manually, both didn't work for running it as a service. What am I missing?

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [September 9, 2024, 12:05pm UTC](https://discuss.elastic.co/t/logstash-keystore-not-working-when-running-logstash-as-a-service/366230/2 "2024-09-09T12:05:37Z")

</div>

I realize 22 is not 14, but [this](https://github.com/elastic/logstash/issues/9711#issuecomment-397396668) might be worth looking at.

---

<div class="post-metadata">

**Author:** ![Raven\_Music](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/raven_music/32/137422_2.png) [@Raven\_Music](https://discuss.elastic.co/u/Raven_Music)\
**Post date:** [September 10, 2024, 1:43pm UTC](https://discuss.elastic.co/t/logstash-keystore-not-working-when-running-logstash-as-a-service/366230/3 "2024-09-10T13:43:56Z")

</div>

Thank you! It worked.
