{"record":{"id":"8cd6e932a54d76f3","repo":"puppetlabs/puppet","slug":"systemd-start-for-name-failed-journalctl-log-f","errorCode":null,"errorMessage":"Systemd start for #{name} failed!\njournalctl log for #{name}:\n#{journalctl_output}","messagePattern":"Systemd start for #(.+?) failed!\njournalctl log for #(.+?):\n#(.+?)","errorType":"exception","errorClass":"Puppet::Error","httpStatus":null,"severity":"error","filePath":"lib/puppet/provider/service/systemd.rb","lineNumber":216,"sourceCode":"    [command(:systemctl), \"stop\", '--', @resource[:name]]\n  end\n\n  def statuscmd\n    [command(:systemctl), \"is-active\", '--', @resource[:name]]\n  end\n\n  def restart\n    daemon_reload?\n    super\n  rescue Puppet::Error => e\n    raise Puppet::Error, prepare_error_message(@resource[:name], 'restart', e)\n  end\n\n  def start\n    daemon_reload?\n    super\n  rescue Puppet::Error => e\n    raise Puppet::Error, prepare_error_message(@resource[:name], 'start', e)\n  end\n\n  def stop\n    super\n  rescue Puppet::Error => e\n    raise Puppet::Error, prepare_error_message(@resource[:name], 'stop', e)\n  end\n\n  def prepare_error_message(name, action, exception)\n    error_return = \"Systemd #{action} for #{name} failed!\\n\"\n    journalctl_command = \"journalctl -n 50 --since '5 minutes ago' -u #{name} --no-pager\"\n    Puppet.debug(\"Running journalctl command to get logs for systemd #{action} failure: #{journalctl_command}\")\n    journalctl_output = execute(journalctl_command)\n    error_return << \"journalctl log for #{name}:\\n#{journalctl_output}\"\n  end\nend\n","sourceCodeStart":198,"sourceCodeEnd":233,"githubUrl":"https://github.com/puppetlabs/puppet/blob/e227c27540975c25aa22d533a52424a9d2fc886a/lib/puppet/provider/service/systemd.rb#L198-L233","documentation":"Raised by Puppet's systemd service provider when starting a service fails. `start` performs a daemon-reload, calls the base provider's start (which runs `systemctl start <name>`), and on Puppet::Error re-raises with the unit's last 50 journalctl lines from the past 5 minutes. The systemd start failing is the real error; the appended log is there to surface the unit's own output.","triggerScenarios":"`ensure => running/stopped` sync (or an explicit start) where `systemctl start <name>` returns non-zero: unit file absent or malformed, ExecStart points to a nonexistent path, the process exits immediately after fork, a dependency unit failed, or the service is already rate-limited by systemd.","commonSituations":"First run after installing a new service package where the unit was not yet reloaded; ExecStart binary not shipped or not executable; application fails on startup due to bad config or an occupied port; missing Environment/EnvironmentFile referenced by the unit.","solutions":["Inspect the journalctl block inside the error message — it usually contains the application's startup traceback or systemd's complaint about the unit.","Confirm the unit exists and is valid: `systemctl cat <name>` and `systemd-analyze verify <unit-file>`.","Test manually on the node: `systemctl start <name>` then `systemctl status <name>` to reproduce outside Puppet.","If the service is slow to start, raise the resource's `timeout` attribute (default 60s) so Puppet does not fail while the unit is still starting.","If start failed previously and the unit is in failed state, `systemctl reset-failed <name>` before retrying."],"exampleFix":"# before\nservice { 'myapp': ensure => running }\n# after\nservice { 'myapp':\n  ensure     => running,\n  timeout    => 300,\n  hasrestart => true,\n  require    => Package['myapp'],\n}","handlingStrategy":"validation","validationCode":"Puppet::Util::Execution.execute(['systemctl', 'is-enabled', 'myapp'], failonfail: false)\n# and confirm the unit parses:\nsystemd-analyze verify /etc/systemd/system/myapp.service","typeGuard":null,"tryCatchPattern":"begin\n  provider.start\nrescue Puppet::Error => e\n  raise unless e.message.start_with?('Systemd start for')\n  logs = e.message[/journalctl log for .*:\\n(.*)\\z/m, 1]\n  # decide: config error (fail run) vs transient (retry once)\nend","preventionTips":["Order Package/File(unit) -> Service so the unit exists before start is attempted.","Raise `timeout` for slow starters instead of letting the 60s default fail the start.","Reset failed state (`systemctl reset-failed`) in provisioning flows before starting rate-limited units."],"tags":["systemd","service-management","puppet","journalctl"],"backgroundTag":"systemd-service-start-failure","analyzedSha":"e227c27540975c25aa22d533a52424a9d2fc886a","analyzedAt":"2026-08-21T20:49:46.650Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}