A systemd service that will not load and shows bad-setting
Loaded: bad-settingShort answer
bad-setting is the load state systemd gives a unit when an essential setting in its file could not be parsed or is not allowed. Run systemd-analyze verify on the file first. The usual causes are a service with no ExecStart, a relative path in ExecStart, several commands in a non-oneshot service, or Restart=always on a oneshot.
Fix it fast
1Find out which cause you have
Let systemd check the file itself. It prints a line number for every directive it could not accept; read those lines before changing anything.
systemd-analyze verify /etc/systemd/system/myapp.service2Match what you see, then jump to its fix
- 1
The [Service] section has no ExecStart= or ExecStop= line, or the key is misspelledThe service has no ExecStart= and no ExecStop=Fix - 2
systemd-analyze verify reports the ExecStart line, or ExecStart= starts with ./ or a bare relative pathExecStart= does not start with an absolute pathFix - 3
The unit has two or more ExecStart= lines and Type is simple, exec, forking or notifyMore than one ExecStart= in a service that is not Type=oneshotFix - 4
Type=oneshot together with Restart=always (or Restart=on-success)Restart=always or on-success on a Type=oneshot serviceFix
- 1
What does the error look like?
Loaded: bad-settingbad-setting in the LOAD column of systemctl list-unitsUnknown key name 'ExecStar' in section 'Service', ignoring.
Cause 1 of 4
The service has no ExecStart= and no ExecStop=
1Check
A service unit that defines neither ExecStart= nor ExecStop= is not valid. A typo in the key name (for example ExecStar=) leaves the section without a command, because unknown keys are only warned about and then skipped.
grep -n -E "^(ExecStart|ExecStop)" /etc/systemd/system/myapp.service
systemd-analyze verify /etc/systemd/system/myapp.service2Fix
Add the command that runs your program. If the unit really only runs a stop command, it must also set RemainAfterExit=yes.
[Service]
ExecStart=/usr/bin/node /srv/myapp/server.js3Verify
Reload the manager and read the Loaded line again.
sudo systemctl daemon-reload
systemctl status myapp.serviceConfirmed by man7.org
Cause 2 of 4
ExecStart= does not start with an absolute path
1Check
The first word of an ExecStart= command must be an absolute path (or a plain program name that systemd can find in its fixed search path). A relative path such as ./run.sh or app/run.sh is not valid.
grep -n "^ExecStart" /etc/systemd/system/myapp.service
command -v node2Fix
Replace the value with the full path to the executable. Use command -v to get it.
[Service]
ExecStart=/usr/bin/node /srv/myapp/server.js3Verify
Verify the file and reload.
systemd-analyze verify /etc/systemd/system/myapp.service
sudo systemctl daemon-reloadConfirmed by man7.org
Cause 3 of 4
More than one ExecStart= in a service that is not Type=oneshot
1Check
Unless Type= is oneshot, exactly one command may be given in ExecStart=. Copy-pasted unit files often leave two lines in place.
grep -n -E "^(Type|ExecStart)" /etc/systemd/system/myapp.service2Fix
Keep one ExecStart= line. Put the extra commands in ExecStartPre= or ExecStartPost=, or write a small wrapper script and start that.
[Service]
ExecStartPre=/usr/bin/mkdir -p /run/myapp
ExecStart=/usr/bin/node /srv/myapp/server.js3Verify
Reload and start the unit.
sudo systemctl daemon-reload
sudo systemctl start myapp.serviceConfirmed by man7.org
Cause 4 of 4
Restart=always or on-success on a Type=oneshot service
1Check
systemd rejects always and on-success for oneshot services, and a oneshot service is never restarted after a clean exit.
grep -n -E "^(Type|Restart)=" /etc/systemd/system/myapp.service2Fix
Use Restart=on-failure for a oneshot job, or change Type= if the program is a long-running daemon. For something that must run again on a schedule, use a timer unit instead of Restart=.
[Service]
Type=oneshot
Restart=on-failure3Verify
Reload and read the status.
sudo systemctl daemon-reload
systemctl status myapp.serviceConfirmed by man7.org
How do I stop it coming back?
- Run systemd-analyze verify on every unit file before you copy it into /etc/systemd/system.
- Always use absolute paths in ExecStart=, and find them with command -v.
- Run sudo systemctl daemon-reload after every edit of a unit file.
- Start from a small unit with one ExecStart= and add settings one at a time.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Related fixes
Servers
systemctl shows code=exited, status=217/USER
Main process exited, code=exited, status=217/USER
Exit status 217/USER means systemd could not find or switch to the account named in User= before starting the program.
2 causes, each with a fixServers
dnf cannot install MySQL on Amazon Linux 2023
dnf cannot find a mysql-server package on Amazon Linux 2023
Amazon Linux 2023 documents MariaDB, not MySQL, as its database server, with packages named mariadb105 and mariadb105-server.
3 causes, each with a fixServers
Ansible hangs, then times out waiting for the sudo prompt
a playbook using become seems to hang
Ansible ran sudo on the target and never saw the answer it expected.
3 causes, each with a fixServers
Apache on Ubuntu returns 404 Not Found for my site
The requested URL was not found on this server.
On Ubuntu a 404 from Apache usually means the request maps to a path that has no file.
3 causes, each with a fixServers
Apache returns 504 Gateway Timeout when PHP takes too long
Quick requests work, slow ones end in a 504 after a fixed wait
A 504 from Apache means the backend did not answer within the proxy timeout.
2 causes, each with a fixServers
Apache logs SIGWINCH and exits on its own
the httpd container stops although nothing crashed
SIGWINCH is Apache's graceful-stop signal.
2 causes, each with a fix