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.

Introduction & Quick Summary
A service that worked in a shell refuses to start under systemd:
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.
systemctl status nginx.service --no-pager
journalctl -xeu nginx.service --no-pager -n 80The 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:
# /etc/systemd/system/demo.service
[Unit]
Description=demo
[Service]
Type=simple
ExecStart=/opt/demo/start.sh
Restart=on-failure
[Install]
WantedBy=multi-user.targetsudo 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:
| Status | Name | Meaning |
|---|---|---|
1/FAILURE | generic | the program exited with 1 |
2/INVALIDARGUMENT | invalid argument | shell builtin misuse, bad CLI flag |
126 | not executable | file exists, execute bit missing |
127 | not found | command not on the unit's PATH |
200/CHDIR | chdir failed | WorkingDirectory does not exist |
203/EXEC | exec failed | ExecStart missing, wrong interpreter, mount noexec |
209/STDOUT | stdout setup | StandardOutput target invalid |
217/USER | user lookup | User= does not exist |
226/NAMESPACE | namespace | sandboxing directive blocks a path |
233/CGROUP | cgroup setup | resource control limit misconfigured |
Key Comparison Table
The message variants say different things about when the failure happened:
| Message | Failure point | Where to look |
|---|---|---|
control process exited with error code | process ran, then exited non-zero | the app's own log lines |
start operation timed out | Type=notify/forking never signalled ready | readiness protocol, TimeoutStartSec |
failed with result 'exit-code' | same as the first, newer wording | process status line |
Unit X.service not found | unit file absent or not reloaded | daemon-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:
| Directive | Default | Breaks when |
|---|---|---|
ExecStart= | none, required | relative path, shell syntax, ~ |
WorkingDirectory= | / | relative paths inside the app |
User= / Group= | root | files owned by your login user |
Environment= | none | a variable your shell exported but the unit does not |
EnvironmentFile= | none | missing file, KEY = value with spaces around = |
ExecStartPre= | none | failing script, wrong ordering |
Practical Edge Cases, Error Fixes & Deep Dive Code Examples
1. Read the status block in order
● 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.jssystemd 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
[Service]
Environment=NODE_ENV=production
EnvironmentFile=/etc/demo/env# /etc/demo/env
DATABASE_URL=postgres://demo@127.0.0.1/demo
PORT=3000Nothing 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=
[Service]
User=demo
Group=demo
WorkingDirectory=/srv/demo
ProtectSystem=strict
ReadWritePaths=/srv/demo/data
PrivateTmp=true217/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
[Service]
Type=notify
NotifyAccess=main
TimeoutStartSec=30
Restart=on-failure
RestartSec=5
StartLimitIntervalSec=60
StartLimitBurst=5A 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 documentationThe Linux documentation that defines the behaviour this guide explains.
Try matching browser tools
All toolsSmall utilities that fit Linux work — they run entirely in this browser tab, so nothing you paste leaves your device.
Related Linux guides
All Linux guidesnginx 502 Bad Gateway: upstream connection refused
The log line names the address and errno, which is the diagnosis. Fix the host, the start-up order, the buffers, or the timeout that actually fired.
Linux: Read-only file system (EROFS) on a mounted volume
EROFS is a mount condition, not a permission error. Read the kernel log first: I/O errors, a full thin pool, an ro fstab entry or a read-only root.
Linux Networking Diagnostics: ss, ip, dig, curl, and TCP Troubleshooting
A layer-by-layer path from interface to TLS that localises a failure in five commands, with the socket states and curl timings that identify each cause.
apt: The repository does not have a Release file
apt disables any repository whose Release file returns 404. Correct the suite name, move an end-of-life release to the archive host, or remove a dead repo.
More in Linux
All Linux guidesThe guides filed next to this one in Linux, in library order.