Table of Contents
Services that fail after a reboot usually indicate configuration issues, missing dependencies, or incorrect systemd settings. This problem is common on VPS servers running Docker, web servers, or custom apps.
Step 1: Check Service Status After Reboot
Start by checking whether the service is running or failed.
sudo systemctl status nginx
Look for failed, inactive, or error messages in the output.
Step 2: Verify Service Is Enabled at Boot
A service will not start after reboot unless it is enabled.
sudo systemctl is-enabled nginx
If disabled, enable it:
sudo systemctl enable nginx
Step 3: Review Service Logs for Boot Errors
Check logs from the last boot to identify startup failures.
sudo journalctl -u nginx -b
Errors here usually point directly to the root cause.
Step 4: Check for Missing Dependencies
Some services depend on network, storage, or other services.
sudo systemctl list-dependencies nginx
Ensure required services are not failing.
Step 5: Fix Network-Dependent Services
Services that need network access may start too early.
sudo systemctl edit nginx
[Unit]
After=network-online.target
Wants=network-online.target
Save and reload systemd.
sudo systemctl daemon-reexec
Step 6: Reload systemd and Restart the Service
Apply configuration changes.
sudo systemctl daemon-reload
sudo systemctl restart nginx
Step 7: Test Service Persistence
Reboot the server to confirm the fix.
sudo reboot
After reboot, verify service status again.
sudo systemctl status nginx
You may also want to review this related article: How to Read and Analyze Service Logs on Linux
Optional Step: Delay Service Startup Manually
For stubborn services, add a startup delay.
[Service]
ExecStartPre=/bin/sleep 10
Useful for databases, Docker containers, and custom apps.
