systemd service fails to start with status=203/EXEC for Node app after unit file change
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
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
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
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
- 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.
- 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.
- 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.
- 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.
- 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
No fix has been independently verified for this scenario. Treat the causes below as diagnostic hypotheses.
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?
Verified community troubleshooting
No answers yet..
Incident analysis
Most likely causes
Summary
Suggested Fixes
Continue troubleshooting
Related troubles
Matched from the title, description and tags
- Linux41% match
systemd service ExecStart script returns 'Permission denied' only when run as non-root user after unit file move
Open0 answers - Linux28% match
Ubuntu 22.04 service fails to start after re-encrypting LUKS volume changed partition UUIDs
Open0 answers - Linux28% match
Systemd unit hangs systemd-shutdown when TLS cert-rotation script runs in ExecStop on Ubuntu 22.04
Open0 answers - Linux25% match
systemd socket-activated service times out after moving /var to separate partition
Open0 answers - Linux25% match
Ubuntu 22.04: Docker containers intermittently lose DNS after host switches to systemd-resolved stub resolver during network changes
Solved1 answer