Linux

systemd service fails to start with status=203/EXEC for Node app after unit file change

Environment

Environment

Ubuntu 22.04 VM, Node.js 18 installed via apt, service unit /etc/systemd/system/myapp.service with ExecStart=/usr/local/bin/start-myapp.sh running under appuser.

Symptoms

Symptoms

systemctl start myapp.service fails immediately. systemctl status shows 'status=203/EXEC' and no process ID. Journalctl shows 'Failed to execute binary /usr/local/bin/start-myapp.sh: Permission denied' or '/usr/bin/env: bad interpreter'.

Observations

Observations

start-myapp.sh is a shell wrapper with a #!/usr/bin/env bash shebang. File exists but had been edited by CI and the mode is 0644 (not executable). The unit file uses ExecStart with an absolute path.

Already attempted

Already attempted

Tried sudo chmod +x on the script and reloaded daemon; sometimes error changes to 'No such file or directory' pointing at /usr/bin/env existing. Did not change user in unit file.

Diagnostic steps

Diagnostic steps

  1. Inspect unit status and journal: sudo systemctl daemon-reload; sudo systemctl start myapp.service; sudo systemctl status myapp.service -n 50; sudo journalctl -u myapp.service -n 200 --no-pager
  • What the result means: Journal lines commonly show the underlying exec failure. 'Permission denied' suggests file mode or mount options. 'No such file or directory' with valid path often indicates bad interpreter or CRLF line endings.
  1. Check file permissions, ownership, and shebang: ls -l /usr/local/bin/start-myapp.sh; head -1 /usr/local/bin/start-myapp.sh | sed -n '1p' | od -c | sed -n '1p'
  • What the result means: If script lacks the executable bit, add it. If shebang contains CRLF (\r) bytes or references a non-existent interpreter, fix it. If file owned by root but unit expects different privileges, adjust as needed.
  1. Try running the ExecStart as the target user manually: sudo -u appuser /usr/local/bin/start-myapp.sh
  • What the result means: If it runs interactively, the issue is systemd-specific (environment or security policies). If it fails with same error, the problem is the binary or interpreter.
  1. Verify mount options and binary execution allowed: mount | grep "$(df --output=target /usr/local/bin | tail -1)" and check for 'noexec'. Also check for AppArmor denials in dmesg or audit logs.
  • What the result means: If filesystem mounted with noexec, systemd cannot execute the script; remounting or moving the file is needed. AppArmor denials will appear in dmesg/audit and require profile adjustments.
  1. Validate PATH references inside script and absolute paths to node: which node; sudo -u appuser /usr/bin/node --version (or explicit /usr/bin/env node).
  • What the result means: If /usr/bin/env node is missing because node is in /usr/local/bin, adjust shebang or use an absolute path. If node binary exists but not in PATH for systemd, set Environment=PATH in the unit.
Confirmed fixes

Confirmed fixes

No fix has been independently verified for this scenario. Treat the causes below as diagnostic hypotheses.

Question

Question

What precise checks confirm whether exec path, interpreter, permissions, or SELinux/AppArmor are blocking execution, and what reversible fixes to apply to restore service safely?

COMMUNITY RESPONSES

Verified community troubleshooting

0 replies

No answers yet..

Showing 0 of 0 community responses
AI DIAGNOSTICS

Incident analysis

Updated 3w ago• Trouble ID

Most likely causes

ExecStart path not executable (missing +x) or file owned by wrong user/FS mount noexec. 75%
Shebang references /usr/bin/env but env missing or line endings are CRLF causing '/usr/bin/env: bad interpreter'. 60%
Unit file points to a wrapper that references relative paths not present under systemd PATH. 40%

Summary

status=203/EXEC indicates systemd could not execute the binary specified by ExecStart. Typical causes: missing executable, wrong permissions, bad interpreter shebang pointing to missing binary, or security policy denying exec.

Suggested Fixes

Diagnostic step 1
Inspect unit status and journal: sudo systemctl daemon-reload; sudo systemctl start myapp.service; sudo systemctl status myapp.service -n 50; sudo journalctl -u myapp.service -n 200 --no-pager Result meaning: Journal lines commonly show the underlying exec failure. 'Permission denied' suggests file mode or mount options. 'No such file or directory' with valid path often indicates bad interpreter or CRLF line endings.
Diagnostic step 2
Check file permissions, ownership, and shebang: ls -l /usr/local/bin/start-myapp.sh; head -1 /usr/local/bin/start-myapp.sh | sed -n '1p' | od -c | sed -n '1p' Result meaning: If script lacks the executable bit, add it. If shebang contains CRLF (\r) bytes or references a non-existent interpreter, fix it. If file owned by root but unit expects different privileges, adjust as needed.
Diagnostic step 3
Try running the ExecStart as the target user manually: sudo -u appuser /usr/local/bin/start-myapp.sh Result meaning: If it runs interactively, the issue is systemd-specific (environment or security policies). If it fails with same error, the problem is the binary or interpreter.

Continue troubleshooting

Matched from the title, description and tags