How to restart services safely
The right systemctl commands to restart or reload a Linux service, and why checking its status straight afterwards is not optional.
Use systemctl restart servicename to stop and start a service, or systemctl reload servicename where the service supports it, to re-read its configuration without dropping active connections. Then always check its status immediately afterwards — a restart command that returns cleanly does not by itself guarantee the service actually came back up.
The basic commands
sudo systemctl restart nginx
sudo systemctl status nginx
restart stops the service completely and starts it fresh — necessary when a binary has been updated, or when the service is in a state a reload cannot fix. Any connection open to it at that instant is dropped.
reload asks a running service to re-read its configuration file without a full stop and start, where the service supports it. Nginx, Apache and MariaDB all support it, and it is the better choice after a configuration change alone — active connections are not interrupted.
sudo systemctl reload nginx
Always check the status afterwards
A restart or reload command exiting without an error message is not proof the service is actually running — a bad configuration file can cause a service to fail to come back up at all, and the shell will often say nothing about it. Get in the habit of following every restart with:
sudo systemctl status nginx
Look for active (running) in green. If it instead shows failed, the service did not survive the restart, and the fix is in its logs, not in trying the restart again:
journalctl -u nginx -n 50
Test configuration before you restart, where you can
Nginx, Apache and several other services can validate their own configuration file without applying it — always do this before a restart when you have just edited a config, since it catches a typo before it takes the service down rather than after:
sudo nginx -t
sudo apache2ctl configtest # Debian / Ubuntu
sudo apachectl configtest # RHEL / Rocky / AlmaLinux
If a service will not start at all
Check whether it is enabled to start automatically on boot, separately from whether it is running right now — enable and start are two different things:
sudo systemctl enable --now nginx
enable sets it to launch on the next reboot; --now also starts it immediately, in one command. If it still fails, the journal entry from the failed attempt (journalctl -u nginx -n 50) will almost always name the specific line or setting causing it — see reading Linux server logs for more on interpreting it.
For scheduled restarts — for example, restarting a service automatically after a nightly maintenance task — see setting up a cron job on a VPS.
Related reading
Where Linux keeps its logs, the commands to actually read them, and how to filter thousands of lines down to the one that matters.
How to see what is using your server resourcesThe commands that show you exactly what is consuming CPU, memory and disk on a VPS, and how to identify the process responsible.
How to keep a Linux server patchedUpdating a VPS safely, handling the reboots that kernel updates require, and automating security patches so this stops being a manual chore.
How much RAM does my VPS need?It depends what is running, but free -h on an existing server and a look at what each extra service costs gets you a real answer fast.