Linux Troubleshooting

Restart a failed systemd service on Linux

Bring a service back after you fixed the config — standard recovery flow.

8 min read Beginner Updated 9 Jun 2026

Step-by-step guide

Work through each section in order. Stop when your issue is resolved — you do not need every step for every situation.

Warning

Restarting a service before fixing the underlying config error puts it in a crash loop. Read journalctl output first. After editing unit files, always daemon-reload before restart.

What you will achieve

Recover a failed systemd service on Ubuntu or Debian — diagnose, fix configuration, reload units, restart, enable at boot, and verify it stays running.

1) Check current state

systemctl status nginx.service
systemctl is-active nginx
systemctl is-enabled nginx

failed or inactive (dead) with non-zero exit code needs investigation before blind restart.

2) Read recent logs

sudo journalctl -u nginx.service -b --no-pager -n 50
sudo journalctl -u nginx.service -p err --since "1 hour ago"

Config syntax errors, permission denied, and port-in-use messages appear here — fix the cause, not the symptom.

3) Validate config before restart

sudo nginx -t
sudo sshd -t
sudo apachectl configtest

Service-specific test commands vary. Running restart on broken config wastes time and fills logs.

4) Reload systemd after unit file edits

sudo systemctl daemon-reload

Required when you change /etc/systemd/system/myservice.service or drop-ins under .d/ directories. Skip this and systemd runs the old unit definition.

5) Restart and enable

sudo systemctl restart nginx.service
sudo systemctl enable nginx.service

restart stops then starts. Use reload when the service supports graceful config reload without dropping connections:

sudo systemctl reload nginx.service

6) Reset failed state

sudo systemctl reset-failed nginx.service

Clears the red failed badge after you fixed the issue — cosmetic but helps monitoring tools.

7) If restart keeps failing

systemctl cat nginx.service
sudo systemd-analyze verify nginx.service

Check ExecStart path, User= permissions, and After= ordering. Dependency not ready at boot may need Wants= or correct target.

8) Start vs restart

sudo systemctl start nginx.service    # first start if never run
sudo systemctl try-restart nginx      # restart only if already active

try-restart avoids error noise in automation when the unit was intentionally stopped. Pair with OnFailure= units for alert hooks on production services.

Prerequisites

Root or sudo access, correct unit name (use tab completion with systemctl restart nginx<Tab>), and config validated with the service's own test command before restart.

Verify

systemctl status nginx.service
systemctl is-active nginx
curl -I http://localhost/

Active (running) with clean recent log lines. Reboot test on critical services: sudo reboot, then confirm auto-start.

Related guides

restart systemd troubleshooting