systemctl "Job for service failed": how to find the cause and fix it

"Failed" from systemctl is not one specific error. It means the service itself stopped or could not start, and the reason is recorded in its status and logs. Read those first, fix what they point to, then clear the failed state with `systemctl reset-failed` and start the service again.

Applies to:Linux with systemd
On this page

What it means

When you run systemctl start or systemctl restart and get a message that the job failed, systemctl is only the messenger. It is telling you that the unit (the service) ended up in the failed state. systemd puts a unit there when its process exits with a non-zero code, is killed by a signal, times out, crashes, or runs into its restart limit.

systemd remembers the exit code and status until the unit is started again or you clear it with reset-failed. So the useful part is never the word "failed". It is the reason recorded next to it, and you can read that in a minute.

This page is a general triage routine for any service. If you already know which service is failing (nginx, Docker, a database), a page about that specific service will give you more targeted causes.

Symptoms and causes

You are likely dealing with this problem if:

  • systemctl status name shows Active: failed followed by a Result: such as exit-code, signal or timeout.
  • systemctl --failed lists one or more units, and systemctl is-system-running reports degraded.
  • The service keeps restarting for a short while and then stops being restarted automatically.

The usual causes, most common first:

The program itself fails
A bad config file, a port already in use, missing permissions, or a missing file, directory or dependency makes the service's command exit with an error. The details are in the service's log.
Wrong ExecStart= or User=
The binary in ExecStart= does not exist, or the account in User= does not exist.
Type= does not match how the program behaves
With forking, the unit counts as started when the parent process exits. With notify, the program must send a READY=1 notification. A oneshot unit without RemainAfterExit= never shows as active.
A timeout
The service did not finish starting within TimeoutStartSec= (which defaults to DefaultTimeoutStartSec=; the timeout is off for oneshot), or did not stop within TimeoutStopSec=.
The start rate limit was hit
Starts beyond StartLimitBurst= within StartLimitIntervalSec= are refused, and this includes manual starts. A unit with Restart= that reaches the limit is no longer restarted automatically.
The service was killed for running out of memory
An out-of-memory kill counts as a failure for Restart=on-failure, on-abnormal and always.

How to fix it

Work through these in order. They start with the quickest, safest checks and move to deeper repairs; stop as soon as the problem is gone.

1.Read why the service failed

Easy

Every other fix depends on the reason, and systemd already stored it.

  1. Show the unit's state and its most recent log lines. Replace name with the service, for example nginx.service.
    Terminal
    systemctl status name
  2. To see every failed unit on the machine, not just the one you tried to start, list them.
    Terminal
    systemctl --failed
  3. Note the Result: value and the last error lines in the log. They tell you which of the fixes below applies.

2.Fix the problem the log points to

ModerateChanges settings

Most failures are the program's own complaint: config, port, permissions, path or user.

Before you start: Make a copy of any config file before you edit it, so you can go back.

  1. Match the error to its cause: a syntax error means a config problem, an address-in-use error means another process holds the port, a permission error means the service account cannot read a file or directory, and a not-found error means a path or user is wrong.
  2. If the program has a built-in config test, run it before restarting. For nginx, -t checks the configuration syntax and tries to open the files the configuration refers to.
    Terminalneeds sudo / root
    nginx -t
  3. Correct the config, file permissions, path or User= setting, then start the service again.
    Terminalneeds sudo / root
    systemctl start name

3.Check the unit's own settings

AdvancedChanges settings

If the program runs fine by hand but fails under systemd, the unit's Type=, timeout or restart settings may not match how it behaves.

Before you start: Write down every setting you change so you can undo it. Wrong unit settings can stop a service from starting at all.

  1. Compare Type= with how the program behaves: forking counts the unit as started when the parent process exits (use PIDFile= with it), notify needs the program to send READY=1, and a oneshot unit without RemainAfterExit= never shows as active.
  2. If the service is just slow to start, raise TimeoutStartSec=.
  3. For a long-running service, Restart=on-failure with a RestartSec= value makes systemd retry after a failure.

4.Clear the failed state and the start limit

Easy

After the cause is fixed, reset-failed clears the failed state along with the start-rate-limit and restart counters, so a unit that hit StartLimitBurst= can be started again.

  1. Reset the unit and start it.
    Terminalneeds sudo / root
    systemctl reset-failed name
    systemctl start name
  2. Do this only after fixing the cause. If the cause is still there, the unit will simply fail again.

Check that it worked

  • Run systemctl is-failed name. It exits with code 0 only when the unit is failed, so a non-zero exit means the unit is no longer failed.
  • Run systemctl status name and confirm it shows Active: active.
  • Run systemctl --failed and confirm the unit is gone from the list.

If it still fails

  • Try running the ExecStart= command by hand as the same user the service uses, to see the error directly.
  • Check whether the service is a user unit. Units started with systemctl --user fail separately from system units and have their own status and logs.
  • If the message is about a unit not being found or about connecting to the bus, that is a different problem from a failed service and needs its own troubleshooting.
  • Search for the exact error line from the log together with the service name, or ask the software's own support channel or your distribution's documentation.

Questions

Is it safe to just run reset-failed?

It is harmless, but it only clears the record. If the underlying problem remains, the service will fail again, so fix the cause first.

Why can I not start the service manually after it kept restarting?

The start rate limit probably blocked it. Starts beyond StartLimitBurst= within StartLimitIntervalSec= are refused, including manual ones. Fix the cause, run systemctl reset-failed name, then start it.

Sources

  1. systemctl(1)Official · freedesktop.org systemd project
  2. systemd.service(5)Official · freedesktop.org systemd project
  3. systemd.unit(5)Official · freedesktop.org systemd project
  4. nginx: Command-line parametersOfficial · nginx.org