Published

Linux

Linux Service Won't Start? Find the Real Error (systemctl + journalctl)

When a systemd service fails, the real reason is in its status and its log. These commands find it in under a minute. The examples use nginx; swap in your own service name.

1. Check the status

Shows whether the service is running and the last few log lines, which often contain the error.

systemctl status nginx

2. Read the full log

Shows the last 50 log lines for that service only. Add -f to follow it live while you try again.

journalctl -u nginx -n 50 --no-pager

3. Test the config before restarting

Many services can check their own config. A typo in a config file is the most common reason a service will not start.

sudo nginx -t
sudo apachectl configtest
sudo sshd -t

4. Restart and check what else failed

After fixing the error, restart the service and list any other failed units.

sudo systemctl restart nginx
systemctl --failed

FAQ

The service starts, then stops a few seconds later. Why?

The program is crashing after start. journalctl -u name -n 100 shows its last messages; look for a missing file, a port already in use or a permission error.

How do I make a service start at boot?

sudo systemctl enable –now name enables it at boot and starts it right away.