# File output - Logstash is unable to create directory and write a file due to permission denied error

**URL:** <https://discuss.elastic.co/t/file-output-logstash-is-unable-to-create-directory-and-write-a-file-due-to-permission-denied-error/209638>\
**Category:** Logstash\
**Created:** [November 27, 2019, 9:16am UTC](https://discuss.elastic.co/t/file-output-logstash-is-unable-to-create-directory-and-write-a-file-due-to-permission-denied-error/209638 "2019-11-27T09:16:12Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![saif3r](https://avatars.discourse-cdn.com/v4/letter/s/49beb7/32.png) [@saif3r](https://discuss.elastic.co/u/saif3r)\
**Post date:** [November 27, 2019, 9:16am UTC](https://discuss.elastic.co/t/file-output-logstash-is-unable-to-create-directory-and-write-a-file-due-to-permission-denied-error/209638/1 "2019-11-27T09:16:12Z")

</div>

Hi,

I created a pipeline that outputs the content into home folder of one of the users. When i run the pipeline manually as root, there is no issue, but then i try to do the same using pipelines.yml and logstash service, it generates an error.  
User name: audit

```
ls -l /home/
total 4
drwx------. 4 audit audit 92 Nov 27 08:28 audit

```

I created a folder within /home/audit and changed owner to logstash

```
ls -l /home/audit/
total 0
drwxr-xr-x. 2 logstash logstash 6 Nov 27 10:12 winlog

```

When i run the pipeline using logstash service i got:

```
[2019-11-27T10:15:23,046][INFO][logstash.outputs.file][file_output_pipeline] Opening file {:path=>"/home/audit/winlog/logs/2019_11/2019_11_26.txt"}
[2019-11-27T10:15:23,068][INFO][logstash.outputs.file][file_output_pipeline] Creating directory {:directory=>"/home/audit/winlog/logs/2019_11"}
[2019-11-27T10:15:23,195][INFO][logstash.pipeline] Pipeline started successfully {:pipeline_id=>"file_output_pipeline", :thread=>"#<Thread:0x5d316a0b@/usr/share/logstash/logstash-core/lib/logstash/pipeline_action/create.rb:37 run>"}
[2019-11-27T10:15:23,251][FATAL][logstash.runner] An unexpected error occurred! {:error=>#<Errno::EACCES: Permission denied - /home/audit/winlog>, :backtrace=>["org/jruby/RubyDir.java:590:in `mkdir'", "uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/fileutils.rb:235:in `fu_mkdir'", "uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/fileutils.rb:213:in `block in mkdir_p'", "org/jruby/RubyArray.java:1882:in `reverse_each'", "uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/fileutils.rb:211:in `block in mkdir_p'", "org/jruby/RubyArray.java:1800:in `each'", "uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/fileutils.rb:196:in `mkdir_p'", "/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/logstash-output-file-4.2.6/lib/logstash/outputs/file.rb:273:in `open'", "/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/logstash-output-file-4.2.6/lib/logstash/outputs/file.rb:136:in `block in multi_receive_encoded'", "org/jruby/RubyHash.java:1417:in `each'", "/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/logstash-output-file-4.2.6/lib/logstash/outputs/file.rb:135:in `block in multi_receive_encoded'", "org/jruby/ext/thread/Mutex.java:160:in `synchronize'", "/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/logstash-output-file-4.2.6/lib/logstash/outputs/file.rb:134:in `multi_receive_encoded'", "/usr/share/logstash/logstash-core/lib/logstash/outputs/base.rb:87:in `multi_receive'", "org/logstash/config/ir/compiler/OutputStrategyExt.java:118:in `multi_receive'", "org/logstash/config/ir/compiler/AbstractOutputDelegatorExt.java:101:in `multi_receive'", "/usr/share/logstash/logstash-core/lib/logstash/pipeline.rb:394:in `block in output_batch'", "org/jruby/RubyHash.java:1417:in `each'", "/usr/share/logstash/logstash-core/lib/logstash/pipeline.rb:393:in `output_batch'", "/usr/share/logstash/logstash-core/lib/logstash/pipeline.rb:345:in `worker_loop'", "/usr/share/logstash/logstash-core/lib/logstash/pipeline.rb:308:in `block in start_workers'"]}
[2019-11-27T10:15:23,554][ERROR][org.logstash.Logstash] java.lang.IllegalStateException: Logstash stopped processing because of an error: (SystemExit) exit
```

---

<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:** [November 27, 2019, 4:44pm UTC](https://discuss.elastic.co/t/file-output-logstash-is-unable-to-create-directory-and-write-a-file-due-to-permission-denied-error/209638/2 "2019-11-27T16:44:14Z")

</div>

You need at least execute access on each component of the path to access a file.

```
 chmod o+x /home
```

---

<div class="post-metadata">

**Author:** ![saif3r](https://avatars.discourse-cdn.com/v4/letter/s/49beb7/32.png) [@saif3r](https://discuss.elastic.co/u/saif3r)\
**Post date:** [November 29, 2019, 2:28pm UTC](https://discuss.elastic.co/t/file-output-logstash-is-unable-to-create-directory-and-write-a-file-due-to-permission-denied-error/209638/3 "2019-11-29T14:28:45Z")

</div>

That did the trick, thank you very much.

---

<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:** [December 27, 2019, 2:28pm UTC](https://discuss.elastic.co/t/file-output-logstash-is-unable-to-create-directory-and-write-a-file-due-to-permission-denied-error/209638/4 "2019-12-27T14:28:51Z")

</div>

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