why won't a service start
Read what a systemd service said when it failed, check its unit file and its configuration, then start it again.
Steps
-
systemctl status NAMEits state, its last log lines and its exit code
-
journalctl -u NAME -b -n 50 --no-pagerits last 50 log lines since the machine started
-
systemctl cat NAMEthe unit file it runs: the command, the user, the paths
-
systemd-analyze verify NAME.servicelook for mistakes in the unit file
-
sudo ss -tulpnsee whether another program already holds its port
-
sudo systemctl daemon-reloadafter editing a unit file, make systemd read it again
-
sudo systemctl restart NAMEstart it again, then look at its status
Notes
- Put the service's name in place of NAME:
nginx,ssh,docker. - Many services check their own configuration:
sudo nginx -t,sudo apachectl configtest,sudo sshd -t. - "Permission denied" in the log often means a file or folder it needs belongs to another user.
- macOS uses launchd:
launchctl list | grep NAME, and its logs withlog show --last 10m.
Commands used
systemctljournalctlsystemd-analyze
Each has a page in lore: lore systemctl opens it.
Related recipes
- read the system logsFind what went wrong: the errors since boot, a service's log, the kernel's messages.
- schedule a command with cronRun a command every day, every hour or every few minutes, and see what is scheduled.
- add a userCreate an account with a home folder and a password, and let it use sudo if it should.
- count the processorsHow many processors and cores this machine has, and what they are.