Pages

Topics

Tools

↑↓navigate↵openescclose
All guides

systemd: Job for X.service failed because the control process exited

systemd only reports that the process exited non-zero. Read the status line, decode the status code and compare the unit's environment with your shell.

~5 min readLinux
#systemd#linux#services#troubleshooting
Bold white headline reading SERVICE FAILED with a systemd unit crate stopped at an amber exit status board and a cyan journal stream.

Introduction & Quick Summary

A service that worked in a shell refuses to start under systemd:

code
Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xeu nginx.service" for details.

Quick answer: read the exit status systemd already recorded, then look at the unit's own log lines.

bash
systemctl status nginx.service --no-pager journalctl -xeu nginx.service --no-pager -n 80

The message is a wrapper. systemd started the process, the process exited with a non-zero status, and systemd reports that fact without interpreting it. Everything you need is in the two commands above: Process: <pid> ExecStart=... (code=exited, status=1/FAILURE) tells you which status, and the journal lines immediately before it carry the program's own output. The work is in reading those two things together.

Core Mechanics, Signatures & Reproducible Setup

A service enters failed when its main process exits non-zero before systemd considers it started, or when ExecStartPre, ExecStartPost or the readiness check fails. Type=simple is treated as started immediately, so an exit one second later is still a failure. Type=notify and Type=oneshot have sharper rules, which matters when the program is fine but the unit type is wrong.

Reproduce it with a unit whose path is wrong:

ini
# /etc/systemd/system/demo.service [Unit] Description=demo [Service] Type=simple ExecStart=/opt/demo/start.sh Restart=on-failure [Install] WantedBy=multi-user.target
bash
sudo systemctl daemon-reload sudo systemctl start demo systemctl status demo --no-pager # Process: 5123 ExecStart=/opt/demo/start.sh (code=exited, status=203/EXEC)

status=203/EXEC is systemd's own code meaning it could not execute the binary — a different answer from the app printing 127. Learning the handful of systemd-specific codes turns most of these into a one-minute fix:

StatusNameMeaning
1/FAILUREgenericthe program exited with 1
2/INVALIDARGUMENTinvalid argumentshell builtin misuse, bad CLI flag
126not executablefile exists, execute bit missing
127not foundcommand not on the unit's PATH
200/CHDIRchdir failedWorkingDirectory does not exist
203/EXECexec failedExecStart missing, wrong interpreter, mount noexec
209/STDOUTstdout setupStandardOutput target invalid
217/USERuser lookupUser= does not exist
226/NAMESPACEnamespacesandboxing directive blocks a path
233/CGROUPcgroup setupresource control limit misconfigured

Key Comparison Table

The message variants say different things about when the failure happened:

MessageFailure pointWhere to look
control process exited with error codeprocess ran, then exited non-zerothe app's own log lines
start operation timed outType=notify/forking never signalled readyreadiness protocol, TimeoutStartSec
failed with result 'exit-code'same as the first, newer wordingprocess status line
Unit X.service not foundunit file absent or not reloadeddaemon-reload, file path
result 'signal'killed by a signal (OOM, segfault)dmesg, exit status 9/KILL

And the directives that account for most environment differences:

DirectiveDefaultBreaks when
ExecStart=none, requiredrelative path, shell syntax, ~
WorkingDirectory=/relative paths inside the app
User= / Group=rootfiles owned by your login user
Environment=nonea variable your shell exported but the unit does not
EnvironmentFile=nonemissing file, KEY = value with spaces around =
ExecStartPre=nonefailing script, wrong ordering

Practical Edge Cases, Error Fixes & Deep Dive Code Examples

1. Read the status block in order

text
● demo.service - demo Loaded: loaded (/etc/systemd/system/demo.service; enabled; preset: enabled) Active: failed (Result: exit-code) since Thu 2026-11-26 19:02:11 KST; 3s ago Process: 5123 ExecStart=/opt/demo/start.sh (code=exited, status=203/EXEC) Main PID: 5123 (code=exited, status=203/EXEC)

Loaded confirms which file is in effect and whether it is enabled. Process gives the status code. If Main PID is absent entirely, systemd never created a process and you are looking at an exec failure rather than an application failure. Result: exit-code versus Result: signal splits the search in half before you read a single log line.

2. ExecStart paths, interpreters and quoting

# works in bash, fails in systemd ExecStart=cd /opt/demo && npm start # explicit and reliable WorkingDirectory=/opt/demo ExecStart=/usr/bin/node /opt/demo/dist/index.js

systemd does not run commands through a shell. &&, pipes, variable expansion, globs and ~ are not interpreted, and the first argument must be an absolute path. ExecStart=/bin/sh -c "cd /opt/demo && ./run.sh" works but hides signals behind the shell, so the process may not stop cleanly. Node projects installed with nvm are the usual victim: the interpreter lives in /home/<user>/.nvm/... and the unit points at a path that only exists in an interactive shell.

3. Environment: your shell is not the unit's environment

ini
[Service] Environment=NODE_ENV=production EnvironmentFile=/etc/demo/env
# /etc/demo/env DATABASE_URL=postgres://demo@127.0.0.1/demo PORT=3000

Nothing from ~/.bashrc, ~/.profile or nvm use reaches a service. PATH is a minimal default without your local bin directories, so ExecStart=npm start fails with status=203/EXEC while the same command works for a logged-in user. Print the real environment once by adding ExecStartPre=/usr/bin/env and reading the journal — that single line answers most "works in shell, fails as a service" reports. The environment variable inspector converts a .env file into the Environment= lines the unit needs.

4. Permissions: User=, ProtectSystem= and PrivateTmp=

ini
[Service] User=demo Group=demo WorkingDirectory=/srv/demo ProtectSystem=strict ReadWritePaths=/srv/demo/data PrivateTmp=true

217/USER means the account does not exist. 200/CHDIR means the working directory is missing or unreadable by that user. 226/NAMESPACE appears when hardening directives remove a path the program needs — a socket in /run, a certificate in /etc, a cache under /var. Start from a working unit and add hardening one directive at a time, checking systemctl status after each; adding five at once makes the resulting failure impossible to attribute.

5. Timeouts, Type= and restart storms

ini
[Service] Type=notify NotifyAccess=main TimeoutStartSec=30 Restart=on-failure RestartSec=5 StartLimitIntervalSec=60 StartLimitBurst=5

A service that logs "start operation timed out" did not send the readiness notification its unit type expects. Switching to Type=simple fixes the symptom for programs that never notify, at the cost of systemd considering them ready too early. When a unit restarts constantly, systemd eventually reports "start request repeated too quickly" and gives up; journalctl -u name -b shows the loop, and systemctl reset-failed name clears the counter after a fix. Timestamps in the journal are the fastest way to match a service failure to a deployment or reboot, and the Unix timestamp converter makes an epoch value from the app's own log comparable.

6. Scheduling neighbours that look identical

A failing *.timer produces the same wording from systemctl start, but the error belongs to the service it triggers. Check systemctl list-timers --all and read the journal of the service, not the timer. For units that run once a day, Persistent=true on the timer catches up after downtime, and a [Install] section with WantedBy=timers.target is required for enable to do anything. Cron syntax in a timer's OnCalendar= differs from crontab notation; the cron expression tool checks which of the two you are writing.

Common Compilation/Runtime Mistakes & Version Gotchas

Editing a unit without daemon-reload. systemctl start keeps using the old definition and the status block shows the old file timestamp. Reload, then restart.

Testing with sudo /opt/app/start.sh. Root has a different PATH, HOME and file access than User=demo. Test with sudo -u demo -- env -i PATH=/usr/bin:/bin /opt/app/start.sh to approximate the unit.

Type=forking without PIDFile=. systemd cannot tell which process is the service, reports a timeout, and may kill the real daemon as an orphan.

Ignoring the exit status because the log is empty. No log lines plus status=203/EXEC means the program never ran; adding logging does not help.

Version notes. systemd 240 introduced the (code=exited, status=...) format that includes the symbolic name, which is why older guides show bare numbers. systemd 246 changed default RestartSec behaviour for Restart=always. systemd 250 added RestartMode= to distinguish "restart on any exit" from "restart only on failure". On distributions where /etc/systemd/system and /usr/lib/systemd/system both contain a unit with the same name, the /etc copy wins — systemctl cat shows the merged result and systemctl edit writes a drop-in instead of copying the file.

A faster loop. Change one thing, then sudo systemctl daemon-reload && sudo systemctl restart name && systemctl status name --no-pager. Three lines, one screen, and the status block says whether the fix landed.

Reference material: systemctl and systemd.service.

Official references

primary documentation

The Linux documentation that defines the behaviour this guide explains.

Try matching browser tools

All tools

Small utilities that fit Linux work — they run entirely in this browser tab, so nothing you paste leaves your device.

All Linux guides

More in Linux

All Linux guides

The guides filed next to this one in Linux, in library order.