GrepBoard/Manuals
605 manuals ·

systemd "code=exited, status=1/FAILURE": find the cause

·Tested on Ubuntu 24.04.5 (Docker) · systemd 255.4 · reproduced with systemd inside a container · 2026-11·Test scope ↓·7 steps

status=1/FAILURE means the program itself exited with code 1. Find the cause in what it logged - journalctl -u, then its own log file, then a manual run.

text
   Main PID: 131 (code=exited, status=1/FAILURE)

status=1/FAILURE reports that systemd did run the program and it exited with code 1. The line carries no cause. The cause is whatever the program wrote to the journal or to its own log file, so the job is to find that line with journalctl -u.

The systemd manual (systemd.exec, Process Exit Codes) lists 1 as EXIT_FAILURE, "Generic failure or unspecified error", and nothing more. Codes of 200 and up (see the table at the end) are what systemd uses when it fails before the program even starts; 1 is a failure inside the program afterwards. That still includes a wrong ExecStart= argument or Environment= value that makes the program exit 1. The output below comes from deliberately failing units in a container (Ubuntu 24.04, systemd 255). The unit is called myapp.

[1] Read the status output and note which line says 1.

console
# systemctl start myapp; echo "rc=$?"# systemctl status myapp --no-pager
output
rc=0…× myapp.service     Loaded: loaded (/etc/systemd/system/myapp.service; static)     Active: failed (Result: exit-code) since Thu 2026-11-12 22:14:32 UTC; 8ms ago   Duration: 2ms    Process: 131 ExecStart=/usr/local/bin/myapp (code=exited, status=1/FAILURE)   Main PID: 131 (code=exited, status=1/FAILURE)        CPU: 1ms Nov 12 22:14:32 server1 systemd[1]: Started myapp.service.Nov 12 22:14:32 server1 myapp[131]: myapp: cannot open /srv/app/config.yml: No such file or directoryNov 12 22:14:32 server1 systemd[1]: myapp.service: Main process exited, code=exited, status=1/FAILURENov 12 22:14:32 server1 systemd[1]: myapp.service: Failed with result 'exit-code'.

Whether the Process: line starts with ExecStart= or ExecStartPre= sends you to step 5. This unit uses the default type (simple), so start returned rc=0 and the failure came afterwards. A successful start does not mean the service is running.

[2] Look in the journal for lines labelled with the program name.

console
# journalctl -u myapp -b --no-pager
output
Nov 12 22:14:32 server1 systemd[1]: Started myapp.service.Nov 12 22:14:32 server1 myapp[131]: myapp: cannot open /srv/app/config.yml: No such file or directoryNov 12 22:14:32 server1 systemd[1]: myapp.service: Main process exited, code=exited, status=1/FAILURENov 12 22:14:32 server1 systemd[1]: myapp.service: Failed with result 'exit-code'.

Lines starting with systemd[1]: report the outcome. A line with the program name and PID, like myapp[131]:, is the cause. Here the config path is wrong, so create the file or fix the argument in ExecStart=. If the program line is there, you are done.

[3] If there are no program lines at all, there are two possibilities. The first is a program that writes only to its own log file.

console
# journalctl -u myapp-filelog -b --no-pager# systemctl cat myapp-filelog --no-pager | grep ^Exec# tail -n 3 /var/log/myapp.log
output
Nov 12 22:14:32 server1 systemd[1]: Started myapp-filelog.service.Nov 12 22:14:32 server1 systemd[1]: myapp-filelog.service: Main process exited, code=exited, status=1/FAILURENov 12 22:14:32 server1 systemd[1]: myapp-filelog.service: Failed with result 'exit-code'.…ExecStart=/usr/local/bin/myapp-filelog…22:14:32 ERROR config.yml missing

The journal holds only systemd's own lines, while the same error sat in /var/log/myapp.log. The log location is in the program's config or docs. If you do not know it, search the config file used by the ExecStart= program for entries starting with log.

[4] If the file has nothing either, the program may be returning 1 without writing any error. First check with systemctl cat that StandardOutput= and StandardError= do not point at a file or null instead of the journal. Then run the same command by hand and check the exit code. myapp-silent below runs a single grep -q ready /srv/app/state, and grep returns 1 when it finds nothing.

console
# journalctl -u myapp-silent -b --no-pager# /usr/local/bin/myapp-silent; echo $?
output
Nov 12 22:14:32 server1 systemd[1]: Started myapp-silent.service.Nov 12 22:14:32 server1 systemd[1]: myapp-silent.service: Main process exited, code=exited, status=1/FAILURENov 12 22:14:32 server1 systemd[1]: myapp-silent.service: Failed with result 'exit-code'.…1

No program line in the journal, and the manual run exits silently with 1. For a script, sh -x /usr/local/bin/myapp-silent shows which command ends it. A manual run can differ from the service in User=, WorkingDirectory= and Environment=, so check the service's values with systemctl show -p User -p WorkingDirectory -p Environment myapp-silent and run under the same conditions.

[5] If the Process: line starts with ExecStartPre=, the main program never started. In that case start itself returns an error.

console
# systemctl start myapp-pre; echo "rc=$?"# systemctl status myapp-pre --no-pager
output
Job for myapp-pre.service failed because the control process exited with error code.See "systemctl status myapp-pre.service" and "journalctl -xeu myapp-pre.service" for details.rc=1…× myapp-pre.service     Loaded: loaded (/etc/systemd/system/myapp-pre.service; static)     Active: failed (Result: exit-code) since Thu 2026-11-12 22:14:32 UTC; 13ms ago    Process: 152 ExecStartPre=/bin/sh -c echo "pre-check: port 8080 is busy" >&2; exit 1 (code=exited, status=1/FAILURE)        CPU: 1ms Nov 12 22:14:32 server1 systemd[1]: Starting myapp-pre.service...Nov 12 22:14:32 server1 sh[152]: pre-check: port 8080 is busyNov 12 22:14:32 server1 systemd[1]: myapp-pre.service: Control process exited, code=exited, status=1/FAILURENov 12 22:14:32 server1 systemd[1]: myapp-pre.service: Failed with result 'exit-code'.Nov 12 22:14:32 server1 systemd[1]: Failed to start myapp-pre.service.

There is no Main PID: line, and the log says Control process exited, not Main process exited. The cause line, sh[152]:, comes from the pre-start check command, so read what ExecStartPre= verifies first.

[6] With Restart=on-failure the state shows as activating (auto-restart), not failed. This is the status one second after starting a unit with RestartSec=30.

console
# systemctl start --no-block myapp-retry; sleep 1# systemctl status myapp-retry --no-pager
output
● myapp-retry.service     Loaded: loaded (/etc/systemd/system/myapp-retry.service; static)     Active: activating (auto-restart) (Result: exit-code) since Thu 2026-11-12 22:14:32 UTC; 1s ago    Process: 157 ExecStart=/usr/local/bin/myapp (code=exited, status=1/FAILURE)   Main PID: 157 (code=exited, status=1/FAILURE)        CPU: 2ms

Result: exit-code and status=1/FAILURE are unchanged; only the state is "waiting to retry". The search order is the same. If it keeps failing until the restart limit stops it, see step 5 of Find the cause when a systemd service is failed.

[7] After fixing the cause, clear the failure record and start again. If you changed the unit file, run daemon-reload first.

console
# systemctl daemon-reload# systemctl reset-failed myapp# systemctl start myapp

Check that status now shows something other than 1.

Status lineMeaningWhere to look
status=1/FAILUREThe program exited with 1 by itselfThis page
status=203/EXECThe executable could not be opened203/EXEC
status=216/GROUPFailed to determine or change group credentials216/GROUP
status=217/USERFailed to determine or change user credentials, or to set up user namespacing217/USER

Analyze your syslog · journal log in the browser ↗ — nothing is uploaded.

#systemd#status-1-failure#journalctl#exit-code