Skip to main content

Systemd Service Failed to Start: A Status and Journal Checklist

Fix a systemd service that failed to start: read systemctl status and journalctl in order, decode exit codes like 203/EXEC, and clear start-limit-hit.

When a systemd service fails to start, systemd has nearly always recorded why. systemctl status shows the Result and the exit status, and journalctl -u shows the last lines the process wrote. Read them in a fixed order and match the exit code to a cause: 203 is a bad ExecStart= path, 217 a missing user, 200 a missing working directory. Then fix the unit, reload, and reset the failed state. We do this every day in DockLab with the terminal and the unit file open side by side.

Quick answer

  • Run sudo systemctl status myapp.service -l --no-pager and note three things: the Loaded: path, the Result: in the Active: line, and the status= on the Process: line.
  • Run sudo journalctl -u myapp.service -b -n 100 --no-pager and find the first error line, not the last.
  • Match the status: 203/EXEC is a bad binary path, 217/USER a missing user, 200/CHDIR a missing working directory, 1/FAILURE is the app itself (read its log), and Result: timeout means it never signalled ready.
  • Fix it with sudo systemctl edit myapp.service (a drop-in), then sudo systemctl daemon-reload if you edited files by hand.
  • If you see start-limit-hit, run sudo systemctl reset-failed myapp.service, then sudo systemctl start myapp.service.

Read systemctl status like a checklist

Most people glance at the red failed and jump to the logs. The status block has four lines that narrow the search before you open any logs. Here is a typical failure:

× myapp.service - My API
     Loaded: loaded (/etc/systemd/system/myapp.service; enabled; preset: enabled)
    Drop-In: /etc/systemd/system/myapp.service.d
             └─override.conf
     Active: failed (Result: exit-code) since Fri 2026-10-30 09:14:02 UTC; 8s ago
    Process: 41822 ExecStart=/srv/myapp/bin/server (code=exited, status=203/EXEC)
   Main PID: 41822 (code=exited, status=203/EXEC)
        CPU: 2ms

Read it top to bottom:

  1. Loaded: check the path. If it's not the file you've been editing, you're editing the wrong one. A Drop-In: line means another file overrides parts of it. systemctl cat myapp.service prints the unit file and every drop-in, each labeled with its filename (systemctl man page). If status says the unit file changed on disk, systemd is still running the old version until you reload.
  2. Active: ... (Result: ...) tells you the kind of failure. The table below covers the common values.
  3. Process: shows which command failed (ExecStartPre=, ExecStart= and so on) and how it ended: code=exited, status=N or code=killed, signal=X. A failing ExecStartPre= stops the service before the main binary ever runs.
  4. The log tail under the block shows the last 10 journal lines by default. -n 50 shows more. Without root or membership in adm or systemd-journal, these lines may not appear at all, which is why we use sudo.
ResultWhat it meansWhere to look next
exit-codeA process exited non-zeroThe status= number, then the journal
signal / core-dumpKilled by a signal or crashedJournal, dmesg, coredumpctl if installed
timeoutDidn't become ready within TimeoutStartSec=Type= mismatch, slow startup, a dependency that hangs
start-limit-hitRestarted too often in a short windowThe earlier failure; this is a symptom, not the cause
oom-killThe kernel OOM killer stopped itMemory limits, dmesg
resourcessystemd couldn't set something up (often a missing PID file)PIDFile= and Type=forking settings

To pull these values in a script, or to read them without the formatting, use:

systemctl show myapp.service -p Result,ExecMainCode,ExecMainStatus,NRestarts

Read the journal for the first error, not the last

The status block shows only a few lines. The journal has the full sequence. These are the commands we use, all documented in the journalctl man page:

# Everything this unit logged since the current boot, last 100 lines
sudo journalctl -u myapp.service -b -n 100 --no-pager

# Only the last ten minutes, without timestamps and hostnames
sudo journalctl -u myapp.service -S "10 min ago" -o cat

# Errors and worse, across all units, this boot
sudo journalctl -b -p err --no-pager

# Watch live while you start it from another pane
sudo journalctl -u myapp.service -f

A few habits help here:

  • Scroll up to the first error. A crash can produce 40 lines of stack trace and shutdown noise. The first error near the start of the log (EADDRINUSE, permission denied, no such file) is usually the cause.
  • -xe is fine for reading but not for sharing. journalctl -xeu myapp adds catalog help text and jumps to the end of the log. The man page asks you not to use -x when attaching output to bug reports, because the extra text clutters the log.
  • A quiet journal is a clue. If the unit's journal has only systemd's own "Failed with result" lines, the process either never started (look for exit codes of 200 and above) or logs to a file. In the second case, check the app's log path, for example /var/log/myapp/ or /srv/myapp/logs/.
  • Check earlier boots if the failure happened at boot: journalctl --list-boots, then journalctl -u myapp.service -b -1.

Map the exit code to a cause

Exit statuses of 200 and above come from systemd itself. They mean the failure happened after systemd forked the process but before your command ran, so the app never saw it. The full table is in systemd.exec. These are the codes we actually run into:

StatusMeaningUsual fix
200/CHDIRWorkingDirectory= doesn't exist or isn't accessibleCreate it, fix ownership, or prefix the path with - to make it optional
203/EXECexecve() failed on the binaryWrong path, missing +x, a script without a shebang, CRLF line endings, a noexec mount
209/STDOUTCouldn't set up StandardOutput=The log file's directory is missing or not writable
216/GROUPGroup= or SupplementaryGroups= failedCreate the group or fix the name
217/USERUser= couldn't be resolvedCreate the user, or fix LDAP/sssd lookups at boot
226/NAMESPACESandboxing setup failedA path in ReadWritePaths= and similar doesn't exist
233/RUNTIME_DIRECTORYCouldn't create RuntimeDirectory=Check the name and conflicting permissions
1/FAILURE, 2, other small numbersYour program exited with an errorRead the app's own log; systemd did its part

The 203/EXEC error deserves a closer look because it has several causes that look identical in status:

# Does the path exist and is it executable for the service user?
ls -l /srv/myapp/bin/server
sudo -u myapp test -x /srv/myapp/bin/server && echo ok

# Is it a script with Windows line endings? Look for ^M or \r
head -1 /srv/myapp/bin/server | od -c | head -2

# Is the filesystem mounted noexec?
findmnt -T /srv/myapp/bin/server -o TARGET,OPTIONS

A script edited on Windows and uploaded unchanged ends its shebang line with a carriage return. The kernel then looks for an interpreter called bash\r, doesn't find it, and you get 203. Also, systemd.service only resolves bare command names against a fixed search path (/usr/local/bin, /usr/bin and their sbin counterparts), not the PATH from your shell. Use absolute paths for anything under /srv, /opt or a version manager's directory.

systemd-analyze verify catches many of these before you start the unit: unknown directives, missing dependencies, and ExecStart= commands that are missing or not executable (systemd-analyze):

sudo systemd-analyze verify /etc/systemd/system/myapp.service

"It works when I run it by hand"

This is the most common frustrating case. The binary runs fine in your SSH session and fails under systemd. The two environments differ in predictable ways:

  • User. You ran it as yourself or as root. The unit runs it as User=myapp, who may not be able to read .env, write to logs/, or open a private key.
  • Environment. systemd doesn't read ~/.bashrc or ~/.profile. Variables set there, including PATH entries from nvm, pyenv or asdf, don't exist inside the service. Put them in Environment= or EnvironmentFile=.
  • Working directory. Without WorkingDirectory=, the process starts in /, so relative paths like ./config.yml fail.
  • Sandboxing. ProtectSystem=strict, ProtectHome=yes or PrivateTmp=yes make paths read-only or hide them entirely.
  • Type mismatch. If the program forks into the background but the unit says Type=simple, systemd sees the main process exit and treats the service as stopped. If the unit says Type=notify and the program never sends READY=1, the start times out after the default 90 seconds (systemd-system.conf). Run the program in the foreground and use Type=simple or Type=exec. With exec, a missing binary or a bad User= makes systemctl start itself fail, which is clearer.

To reproduce the service's conditions instead of guessing, run the command as a transient unit with the same user and directory:

sudo systemd-run --pty --wait --collect \
  -p User=myapp -p WorkingDirectory=/srv/myapp \
  -p EnvironmentFile=/etc/myapp/env \
  /srv/myapp/bin/server

This gives you the systemd environment with output in your terminal. It doesn't copy every sandboxing setting from your unit, so add the relevant -p properties if you suspect one.

One application failure looks like a systemd problem: the port is already taken. The journal shows EADDRINUSE or address already in use, and the status is 1/FAILURE. Find the process holding the port:

sudo ss -ltnp 'sport = :3000'

It's often an old copy you started by hand in a tmux session and forgot about.

Restart loops and start-limit-hit

With Restart=on-failure, a broken service restarts repeatedly until systemd stops trying. By default, more than 5 starts within 10 seconds trips the limit (systemd-system.conf). After that, the unit shows Result: start-limit-hit and refuses further starts, including manual ones (systemd.unit).

start-limit-hit only tells you the service restarted too often. The real error is earlier in the journal. Once you've fixed it:

sudo systemctl reset-failed myapp.service
sudo systemctl start myapp.service

reset-failed clears the failed state and the start-rate counter. If a service legitimately needs time between retries, for example while waiting for a database, add a delay rather than turning the limit off. The limit settings go in [Unit] and the restart settings in [Service]:

[Unit]
StartLimitIntervalSec=120
StartLimitBurst=5

[Service]
Restart=on-failure
RestartSec=5s

If the real problem is ordering (the app starts before the database is ready), After= and Wants= on the database unit fix it properly. Retries only hide the problem. The same reasoning applies inside containers. We cover Docker's version of this loop in Docker container keeps restarting.

Fix the unit without breaking the next upgrade

Don't edit unit files under /usr/lib/systemd/system or /lib/systemd/system that a package installed. A package upgrade will overwrite them. Use a drop-in instead.

  1. Create a drop-in

    Run sudo systemctl edit myapp.service. It opens an editor on /etc/systemd/system/myapp.service.d/override.conf and reloads systemd when you save.

  2. Override only what you need

    List settings such as Environment= and ExecStart= twice: first empty to clear the old value, then with the new one. Otherwise systemd adds the new value to the old one.

    [Service]
    User=myapp
    WorkingDirectory=/srv/myapp
    EnvironmentFile=/etc/myapp/env
    ExecStart=
    ExecStart=/srv/myapp/bin/server --port 3000
    
  3. Verify and reload

    If you edited files by hand rather than through systemctl edit, run sudo systemctl daemon-reload. Then run sudo systemd-analyze verify myapp.service and check systemctl cat myapp.service to confirm systemd loaded what you intended.

  4. Start and watch

    Keep sudo journalctl -u myapp.service -f running in one pane and run sudo systemctl restart myapp.service in another. Then confirm with systemctl is-active myapp.service.

That last step is where a split layout helps. In DockLab we keep the journal in one pane, a shell in the other, and the drop-in open in the remote editor. The Systemd Services plugin lists units by state (running, failed, inactive) and shows each one's journal, which saves typing --failed and -u on a server you rarely touch. If you'd like that setup, download DockLab. Plain ssh and tmux work too, and nothing in this guide depends on DockLab.

When the failed service sits behind nginx

If users report a 502 Bad Gateway, the failed unit may be the backend rather than nginx. Nginx is running fine but has nothing to proxy to. The nginx error log shows connect() failed (111: Connection refused) while connecting to upstream. Check the backend first:

systemctl --failed
sudo systemctl status myapp.service -l --no-pager
sudo tail -n 20 /var/log/nginx/error.log

If the backend is down, this checklist applies to it. If it's up and nginx still returns 502, the cause is usually a wrong port, a socket path mismatch or a timeout. Our nginx 502 bad gateway fix goes through those in order.

Frequently Asked Questions

How do I see why a systemd service failed?

Run sudo systemctl status name.service -l --no-pager and read the Result: and status= values. Then run sudo journalctl -u name.service -b -n 100 --no-pager and look for the first error line. Between them, those two commands explain almost every failure.

What does status=203/EXEC mean?

systemd couldn't execute the command in ExecStart=. The usual causes are a wrong or relative path, a missing executable bit, a script without a valid shebang (often CRLF line endings), or a filesystem mounted noexec. Check with ls -l, findmnt and systemd-analyze verify.

How do I fix start-limit-hit?

First find and fix the error that made the service restart repeatedly. It's earlier in the journal. Then run sudo systemctl reset-failed name.service and start it again. If the service needs time to recover between attempts, set RestartSec= instead of disabling the start limit.

Do I need daemon-reload after editing a unit file?

Yes, if you edited the file directly. Otherwise systemd keeps using the version it loaded earlier, and systemctl status warns that the file changed on disk. systemctl edit reloads for you when you save.

Why does my service work from the shell but not under systemd?

The service runs as a different user, with no shell profile, possibly in / as its working directory, and sometimes inside a sandbox. Variables, PATH entries and relative paths that work in your session don't exist there. Use systemd-run --pty -p User=... to reproduce the service's environment.

Try it on your own servers

SSH, SFTP, a remote editor, a browser and AI in one desktop workspace.

DockLab runs on macOS, Windows and Linux. Start free and keep your whole server workflow in one window.

About the author

· Co-founder, Legacies

Alexandru works on DockLab product and operations, with a focus on how technical teams run their servers day to day.