Prerequisites
Before checking failed services, make sure you have:
- SSH access to your VPS
Method 1: List All Failed Services
Connect to your VPS:
ssh hxroot@YOUR_SERVER_IP -p 22
systemctl --failed
Example output:
UNIT LOAD ACTIVE SUB DESCRIPTION
● nginx.service loaded failed failed nginx - high performance web server
Method 2: Check Status of a Specific Service
systemctl status nginx
Look for Active: failed or exit code.
Method 3: View Service Logs for Failure Reason
journalctl -u nginx -n 50 --no-pager
Look for error messages at the end.
Method 4: Check for Services That Failed on Boot
journalctl -b | grep "failed"
After Identifying a Failed Service
Restart the service:
sudo systemctl restart nginx
Check configuration syntax:
sudo nginx -t
View detailed error:
journalctl -xe -u nginx
Disable a permanently failing service:
sudo systemctl disable nginx
Check for Services That Failed to Start at Boot (But Are Not "Failed" Now)
systemctl list-units --state=failed
Automate Failed Service Alerts
#!/bin/bash
FAILED=$(systemctl --failed --no-legend)
if [ ! -z "$FAILED" ]; then
echo "Failed services: $FAILED" | mail -s "Service Alert" admin@example.com
fi
✅ You can now identify and troubleshoot failed system services on your VPS.