fluent/fluentd · error · Fluent::ConfigError
Cannot access directory for pid file: #{File.dirname(pid_pat
Error message
Cannot access directory for pid file: #{File.dirname(pid_path)} What it means
When the pidfile does not exist yet, fluentd must create it, so it checks that the parent directory is writable (File.writable?(File.dirname(pid_path))) and aborts with this ConfigError when it is not. This covers a missing directory, a read-only mount, or a directory owned by another user. It fires before daemonize, i.e. at option-processing/startup time.
Source
Thrown at lib/fluent/daemonizer.rb:75
end
pid =
begin
Integer(File.read(pid_path), 10)
rescue TypeError, ArgumentError
return # ignore
end
begin
Process.kill(0, pid)
raise Fluent::ConfigError, "pid(#{pid}) is running"
rescue Errno::EPERM
raise Fluent::ConfigError, "pid(#{pid}) is running"
rescue Errno::ESRCH
end
else
unless File.writable?(File.dirname(pid_path))
raise Fluent::ConfigError, "Cannot access directory for pid file: #{File.dirname(pid_path)}"
end
end
end
def install_at_exit_handlers(pidfile)
at_exit do
if File.exist?(pidfile)
File.delete(pidfile)
end
end
end
end
end
View on GitHub (pinned to dd45c6e18d)
Solutions
- Create the directory and hand it to the daemon user: mkdir -p /var/run/fluentd && chown fluent:fluent /var/run/fluentd
- With systemd, use RuntimeDirectory=fluentd so the unit creates /run/fluentd with correct ownership each boot
- Point --daemon at a path in a writable directory (e.g. /var/lib/fluentd or the user's runtime dir)
- For quick tests, use a pidfile under /tmp or the current directory
Example fix
# before $ fluentd --daemon /var/run/fluentd/fluentd.pid ... # dir missing/root-owned # after $ sudo mkdir -p /var/run/fluentd && sudo chown fluent:fluent /var/run/fluentd $ fluentd --daemon /var/run/fluentd/fluentd.pid ...
Defensive patterns
Strategy: validation
Validate before calling
dir = File.dirname(pid_path)
FileUtils.mkdir_p(dir) unless Dir.exist?(dir)
abort "pid dir not writable: #{dir}" unless File.writable?(dir) Prevention
- With systemd use RuntimeDirectory=fluentd so /run/fluentd is recreated per boot
- Pre-create and chown pid directories in your start script
- Avoid /run and /var/run for non-root daemons without a dedicated runtime dir
When it happens
Trigger: fluentd --daemon /var/run/fluentd/fluentd.pid when /var/run/fluentd does not exist or is root-owned 755 and fluentd runs as non-root; pidfile under /run (tmpfs wiped at boot); read-only filesystem mounts.
Common situations: Non-root daemon pointed at /var/run or /run paths; reboot clearing tmpfs directories not recreated by an init script; containers without the runtime dir baked in.
Related errors
- Cannot access pid file: #{pid_path}
- pid(#{pid}) is running
- out_secondary_file: `#{@directory}` should be writable
- Plugin storage path '#{@path}' is not readable/writable
- Directory is not writable for plugin storage file '#{@path}'
AI-assisted analysis of fluent/fluentd@dd45c6e18d (2026-08-21).
Data as JSON: /api/errors/6779f68e5c9c23f4.
Report an issue: GitHub.