Updated: 22 October 2026 · Applies to: Debian 13 (systemd 257) and other systemd distributions: Ubuntu 24.04 and 26.04, AlmaLinux and Rocky Linux 9 and 10
To restart a service on Debian, run sudo systemctl restart SERVICE, for example sudo systemctl restart nginx. To do the same on another server without logging in to it first, add -H user@host: systemctl -H root@203.0.113.10 restart nginx. Both are explained below, with the checks that tell you whether the restart worked.
Restart a service on Debian (on the server itself)
- Restart the service:
sudo systemctl restart nginx
No output means success. Use the unit name without
.service:nginx,apache2,ssh,mariadb,php8.4-fpmand so on. On Debian the SSH service is calledssh; see How to Restart the SSH Service (sshd) on Linux before you restart it over SSH. - Check that it is running again:
systemctl is-active nginx
Output:
active
For more detail (since when, main process, last log lines), use
systemctl status nginx.
Other actions on the same service:
sudo systemctl reload nginxrereads the configuration without stopping the service (open connections stay up). Not every service supports it.sudo systemctl reload-or-restart nginxreloads when the service supports it, otherwise restarts.sudo systemctl stop nginxandsudo systemctl start nginxstop and start it.sudo systemctl enable nginxstarts it at boot (disableturns that off).systemctl is-enabled nginxshows the current setting.- The older form
sudo service nginx restartstill works on Debian and Ubuntu: it passes the request to systemctl. systemd Alternatives to the service, chkconfig and init Commands lists the equivalents.
When the restart fails
If the new configuration has an error, the service does not come back. On Debian 13 with a broken nginx configuration:
Output:
Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xeu nginx.service" for details.
Read the service's recent log lines:
journalctl -u nginx -n 20 --no-pager
In our test, the log named the problem: unknown directive "garbage" in /etc/nginx/conf.d/bad.conf:1. Many services can test their configuration before a restart, which avoids the downtime altogether: nginx -t, apache2ctl configtest, sshd -t.
Other messages you may see:
Failed to restart ngin.service: Unit ngin.service not found.: the name is wrong.systemctl list-units --type=servicelists the services that are loaded; How to List Services and Check Their Status with systemctl has more ways.Failed to restart nginx.service: Access denied: you ran it as a normal user. Putsudoin front.
Control a service on a remote server with systemctl -H
systemctl -H (--host) connects to the other server over SSH and runs the command there. The result prints on your own machine.
- Make sure SSH login works without questions. Key-based login is best:
ssh root@203.0.113.10 true
- Run systemctl with
-H:systemctl -H root@203.0.113.10 restart nginx
systemctl -H root@203.0.113.10 is-active nginx
systemctl -H root@203.0.113.10 status nginx --no-pager
systemctl -H root@203.0.113.10 --failed
If SSH listens on another port, add it after a colon (-H root@203.0.113.10:2222). A cleaner way is a host alias in ~/.ssh/config, which systemctl -H uses too:
Host web1
HostName 203.0.113.10
User root
Port 2222
Then systemctl -H web1 restart nginx is enough. Both machines need systemd: on the remote side, systemctl talks to systemd-stdio-bridge, which is part of systemd.
The simple alternative: ssh with a command
ssh root@203.0.113.10 'systemctl restart nginx && systemctl is-active nginx'
ssh root@203.0.113.10 'journalctl -u nginx -n 30 --no-pager'
This works for any command, including journalctl for the service's logs. If you log in as a normal user with sudo rights, add -t so sudo can ask for your password: ssh -t deploy@203.0.113.10 sudo systemctl restart nginx.
The same service on several servers
for h in web1 web2 db1; do echo "$h: $(ssh $h systemctl is-active nginx)" done
For regular work across many servers, a configuration tool such as Ansible is the better choice, for example ansible webservers -b -m ansible.builtin.systemd -a "name=nginx state=restarted".
Common problems with -H
- "Failed to get properties: Transport endpoint is not connected": the SSH connection failed (wrong host name, port or key). SSH's own error is printed just above it, for example
Could not resolve hostname. Test withssh HOST truefirst. - "Access denied": the remote user may not control services. Connect as root, or use
ssh -t user@host sudo systemctl ....
Official documentation: systemctl (options --host and restart).