Troubleshooting Systemd Service Failed with Status 203 EXEC Error on Ubuntu 22.04 LTS
Resolve 'systemd service failed status 203 EXEC' errors on Ubuntu 22.04 LTS. This guide covers common causes like incorrect paths, permissions, and environment issues.
Resolve 'systemd service failed status 203 EXEC' errors on Ubuntu 22.04 LTS. This guide covers common causes like incorrect paths, permissions, and environment issues.
A systemd service failing to start with status 203 /EXEC indicates that the executable specified in the ExecStart directive could not be executed by systemd. This often leads to critical services, such as web applications, database instances, or background workers, failing to launch, resulting in outages or degraded functionality. For users, this typically manifests as a service not responding, an application failing to load, or logs indicating a service start failure.
Symptom & Error Signature
When a service fails with status 203 /EXEC, the systemctl status command will report an error similar to this:
systemctl status mywebapp.service
× mywebapp.service - My Custom Web Application
Loaded: loaded (/etc/systemd/system/mywebapp.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Mon 2023-10-23 10:30:00 UTC; 1min 2s ago
Process: 1234 ExecStart=/usr/local/bin/start_webapp.sh (code=exited, status=203/EXEC)
CPU: 1ms
Oct 23 10:30:00 myhost systemd[1]: Started My Custom Web Application.
Oct 23 10:30:00 myhost systemd[1]: mywebapp.service: Main process exited, code=exited, status=203/EXEC
Oct 23 10:30:00 myhost systemd[1]: mywebapp.service: Failed with result 'exit-code'.
Oct 23 10:30:00 myhost systemd[1]: mywebapp.service: Consumed 1ms CPU time.
More detailed information, often crucial for debugging, can be found using journalctl:
journalctl -xeu mywebapp.service
Oct 23 10:30:00 myhost systemd[1]: Starting My Custom Web Application...
Oct 23 10:30:00 myhost systemd[1]: mywebapp.service: Failed to execute command: No such file or directory
Oct 23 10:30:00 myhost systemd[1]: mywebapp.service: Failed at step EXEC spawning /usr/local/bin/start_webapp.sh: No such file or directory
Oct 23 10:30:00 myhost systemd[1]: mywebapp.service: Main process exited, code=exited, status=203/EXEC
Oct 23 10:30:00 myhost systemd[1]: mywebapp.service: Failed with result 'exit-code'.
Oct 23 10:30:00 myhost systemd[1]: Failed to start My Custom Web Application.
Or, another common journalctl output for this error:
Oct 23 10:30:00 myhost systemd[1]: mywebapp.service: Failed at step EXEC spawning /usr/local/bin/start_webapp.sh: Permission denied
Root Cause Analysis
The status 203 /EXEC error from systemd signifies that the execve() system call, which systemd uses to launch the process defined in ExecStart (or ExecStop, ExecReload, etc.), failed. This can be attributed to several underlying issues:
- Incorrect Executable Path: The path specified in
ExecStart(e.g.,/usr/local/bin/start_webapp.sh) is wrong. This could be a typo, the file doesn't exist at that location, or it's a relative path that doesn't resolve correctly from theWorkingDirectory. - Missing Executable: The file specified in
ExecStartliterally does not exist on the filesystem. - Permission Denied:
- The executable file lacks execute permissions (
+x) for the usersystemdattempts to run it as (usuallyrootinitially, or the user specified byUser=andGroup=directives). - One or more directories in the path to the executable lack read or execute permissions, preventing
systemdfrom traversing to the file. - The user specified in
User=orGroup=does not exist on the system.
- The executable file lacks execute permissions (
- Incorrect Shebang Line: If
ExecStartpoints to a script (e.g., Bash, Python), the shebang line (#! /path/to/interpreter) at the top of the script is missing, malformed, or points to a non-existent interpreter.systemdrequires a valid shebang to know how to execute the script. - Environment Issues: Although less common for a direct
EXECerror, a critical environment variable required by the kernel to load the executable (e.g.,LD_LIBRARY_PATHfor dynamic libraries) might be missing, or the executable itself is corrupt. - Filesystem Issues: The filesystem where the executable resides might be mounted
noexec, preventing any execution. Type=forkingMisconfiguration: IfType=forkingis used, but theExecStartcommand itself fails to even launch (e.g., due to a bad path or permissions),systemdwon't be able to track the forking parent, resulting in anEXECerror. While less direct, it can sometimes be a symptom of a deeper path/permission problem with the initial command.
Step-by-Step Resolution
Follow these steps to diagnose and resolve the status 203 /EXEC error.
1. Verify Executable Path and Existence
The most common cause is a simple path error.
Check the unit file:
cat /etc/systemd/system/mywebapp.serviceLook for the
ExecStartline. For example:ExecStart=/usr/local/bin/start_webapp.sh.Verify the file exists at the specified path:
ls -l /usr/local/bin/start_webapp.shIf the command returns
ls: cannot access '/usr/local/bin/start_webapp.sh': No such file or directory, you've found the problem. Correct the path in the.servicefile or move/create the executable.Always use absolute paths in
ExecStart. Whilesystemddoes respectPATHfor commands that don't contain a/, it's best practice to be explicit. If you intend to use a command found inPATH(e.g.,ExecStart=nginx), ensure it's in a standard location.
2. Check File Permissions and Executability
Even if the file exists, systemd needs permission to execute it.
Check execute bit:
ls -l /usr/local/bin/start_webapp.shExpected output should show
xfor the owner, group, or others, depending on who is executing it. Example of executable permissions:-rwxr-xr-xExample of missing executable permissions:-rw-r--r--Add execute permissions if missing:
sudo chmod +x /usr/local/bin/start_webapp.shCheck directory permissions: Ensure that all parent directories leading to the executable have read and execute permissions (
r-x) for the user running the service. For/usr/local/bin/start_webapp.sh, check/usr,/usr/local, and/usr/local/bin.ls -ld /usr /usr/local /usr/local/bin
3. Validate Shebang Line for Scripts
If ExecStart points to a script (e.g., shell, Python, Ruby), it must have a valid shebang.
Inspect the script's first line:
head -1 /usr/local/bin/start_webapp.shExpected output:
#!/bin/bash,#!/usr/bin/python3,#!/usr/bin/env node, etc.Verify the interpreter exists:
ls -l /bin/bash # or /usr/bin/python3, etc.If the interpreter specified in the shebang doesn't exist,
systemdwon't know how to run the script.Correct the shebang or install the interpreter: Modify the script to point to the correct interpreter path or install the necessary interpreter.
4. Review User and Group Directives
If your service runs as a non-root user (which is highly recommended for security), ensure that user and group exist and have the necessary permissions.
Check
User=andGroup=in the unit file:cat /etc/systemd/system/mywebapp.serviceLook for lines like
User=webappandGroup=webapp.Verify user and group existence:
id -u webapp id -g webappIf
id: 'webapp': no such user(or group) is returned, create them:sudo adduser --system --no-create-home webapp # For a system user without a home directory # or sudo addgroup webapp sudo usermod -aG webapp existinguser # To add an existing user to the groupRunning services as
rootis a security risk. Always configureUser=andGroup=to run services with the least necessary privileges.
5. Environment Variables and Working Directory
Less common for EXEC failures directly, but worth checking if the executable is dependent on specific environment variables or its current working directory.
Environment=andEnvironmentFile=: Ensure any critical variables are correctly set.cat /etc/systemd/system/mywebapp.service[Service] Environment="MY_VARIABLE=value" EnvironmentFile=/etc/default/mywebappWorkingDirectory=: IfExecStartuses relative paths,WorkingDirectoryis crucial.
In this case,[Service] WorkingDirectory=/opt/mywebapp ExecStart=./bin/start_script.shsystemdwill try to execute/opt/mywebapp/bin/start_script.sh.
6. Reload Systemd Daemon and Restart Service
After making any changes to the .service file or permissions, you must reload the systemd daemon and restart the service.
Reload daemon:
sudo systemctl daemon-reloadForgetting
daemon-reloadis a common mistake.systemdwill not pick up unit file changes until this command is run.Restart service:
sudo systemctl restart mywebapp.serviceCheck status again:
systemctl status mywebapp.service journalctl -xeu mywebapp.serviceReview the logs for new errors or successful startup.
7. Advanced Debugging with strace
If the issue persists and simple checks don't reveal the problem, strace can help understand exactly what system calls are failing.
Temporarily modify
ExecStart: Edit your.servicefile to prependstrace -f -o /tmp/mywebapp_strace.logto yourExecStartcommand.[Service] ExecStart=/usr/bin/strace -f -o /tmp/mywebapp_strace.log /usr/local/bin/start_webapp.shstraceadds significant overhead and should only be used for debugging. Remove it from yourExecStartline once debugging is complete.Reload and restart:
sudo systemctl daemon-reload sudo systemctl restart mywebapp.serviceAnalyze
straceoutput:cat /tmp/mywebapp_strace.logLook for
execvecalls and their return values (e.g.,-1 EACCESfor permission denied,-1 ENOENTfor no such file).
By systematically following these steps, you should be able to pinpoint and resolve the status 203 /EXEC error, restoring your systemd service to full functionality.
Our Production Verification Guarantee
Encountering a bug not covered here or running a non-standard kernel configuration? Our solutions are continually refined against real production incidents. Submit an environment trace for our editorial team to replicate.