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.
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 nameshowsActive: failedfollowed by aResult:such asexit-code,signalortimeout.systemctl --failedlists one or more units, andsystemctl is-system-runningreportsdegraded.- 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 inUser=does not exist. - Type= does not match how the program behaves
- With
forking, the unit counts as started when the parent process exits. Withnotify, the program must send aREADY=1notification. Aoneshotunit withoutRemainAfterExit=never shows as active. - A timeout
- The service did not finish starting within
TimeoutStartSec=(which defaults toDefaultTimeoutStartSec=; the timeout is off foroneshot), or did not stop withinTimeoutStopSec=. - The start rate limit was hit
- Starts beyond
StartLimitBurst=withinStartLimitIntervalSec=are refused, and this includes manual starts. A unit withRestart=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-abnormalandalways.
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
Every other fix depends on the reason, and systemd already stored it.
- Show the unit's state and its most recent log lines. Replace
namewith the service, for examplenginx.service.systemctl status name - To see every failed unit on the machine, not just the one you tried to start, list them.
systemctl --failed - 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
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.
- 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.
- If the program has a built-in config test, run it before restarting. For nginx,
-tchecks the configuration syntax and tries to open the files the configuration refers to.nginx -t - Correct the config, file permissions, path or
User=setting, then start the service again.systemctl start name
3.Check the unit's own 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.
- Compare
Type=with how the program behaves:forkingcounts the unit as started when the parent process exits (usePIDFile=with it),notifyneeds the program to sendREADY=1, and aoneshotunit withoutRemainAfterExit=never shows as active. - If the service is just slow to start, raise
TimeoutStartSec=. - For a long-running service,
Restart=on-failurewith aRestartSec=value makes systemd retry after a failure.
4.Clear the failed state and the start limit
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.
- Reset the unit and start it.
systemctl reset-failed name systemctl start name - 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 nameand confirm it showsActive: active. - Run
systemctl --failedand 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 --userfail 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
- systemctl(1)Official · freedesktop.org systemd project
- systemd.service(5)Official · freedesktop.org systemd project
- systemd.unit(5)Official · freedesktop.org systemd project
- nginx: Command-line parametersOfficial · nginx.org