Common Issues
Service Won't Start
How to diagnose and fix a Linux service that won't start or crashes continuously
Check service status
systemctl status service-nameThe output shows if the service is active (running), failed, or inactive.
Read the service logs
# Last 50 logs
journalctl -u service-name -n 50
# Real-time logs (useful to see what happens on restart)
journalctl -u service-name -f
# Logs from last system boot
journalctl -u service-name -bBasic systemd commands
# Start
systemctl start service-name
# Stop
systemctl stop service-name
# Restart
systemctl restart service-name
# Reload configuration without downtime
systemctl reload service-name
# Enable on automatic startup
systemctl enable service-name
# Disable automatic startup
systemctl disable service-nameDiagnosis for specific service
Nginx won't start
# Test configuration
nginx -t
# See the specific error
journalctl -u nginx -n 20Common causes:
- Syntax error in configuration file
- Port 80 or 443 already used by another process
- SSL certificate file missing or expired
Apache won't start
apache2ctl configtest
journalctl -u apache2 -n 20MySQL / MariaDB won't start
journalctl -u mariadb -n 30
# or
cat /var/log/mysql/error.log | tail -30Common causes:
- Disk full (MySQL can't write)
- Database corruption (after a crash)
- Wrong configuration in
/etc/mysql/
To repair corrupted tables:
mysqlcheck --all-databases --auto-repair -u root -pPHP-FPM won't start
journalctl -u php8.2-fpm -n 20
php-fpm8.2 --testPort already in use
Often a service won't start because its port is already in use:
# Who uses port 80?
ss -tlnp | grep :80
# or
lsof -i :80# Kill the process using the port
kill -9 PIDService crashes in loop
If a service keeps crashing, systemd puts it in "failed" state after a while:
# Reset failure counter
systemctl reset-failed service-name
# Then restart
systemctl start service-nameServices in failed state
# List all services in error
systemctl --failedPermission problem
Sometimes a service won't start because it doesn't have permissions on its files:
# Check file owner (example for nginx)
ls -la /var/www/example.com/
ls -la /etc/nginx/
# Fix permissions
chown -R www-data:www-data /var/www/example.com/
chmod -R 755 /var/www/example.com/