Skip to content

35. Troubleshooting Guide

When production environments experience an outage, panic is the enemy of recovery. Amateur engineers restart services at random, reboot servers blindly, or change permissions without understanding the root cause—often destroying critical log evidence in the process.

Senior DevOps and SysAdmin professionals follow a disciplined, hypothesis-driven Troubleshooting Methodology.

1. Identify Problem (Understand symptoms, user impact, scope)
↓
2. Collect Data (Inspect logs, metrics, alerts, recent git/infra changes)
↓
3. Reproduce (Can you reliably trigger the failure in a controlled way?)
↓
4. Isolate & Hypothesize (Narrow down to one specific component or layer)
↓
5. Implement Fix (Apply the minimal, targeted change to resolve)
↓
6. Verify (Prove the issue is resolved and test for regressions)
↓
7. Document (Post-Mortem) (Root Cause Analysis, runbook updates, blameless review)

Never start fixing before clearly understanding the symptom:

  • What is actually broken? (“Database returning HTTP 500” vs “Slow API response”).
  • What is the scope? (Is it affecting all users, or only users in a specific region? One node or the entire cluster?).
  • When did it start? (Did it coincide with a code deploy, a kernel update, or a certificate renewal?).

Step 2: Collect Information & Preserve State

Section titled “Step 2: Collect Information & Preserve State”

Before restarting services or clearing caches, collect the live state:

  • Check recent changes: uptime, who -b, git log -n 5, history | tail -n 25.
  • Check active errors: journalctl -p 3 -xb (priority: error/critical/alert).
  • Check kernel events: dmesg -T | tail -n 50.

If you cannot reproduce an issue, you cannot confirm when it is fixed.

  • Use curl -v to reproduce HTTP errors with full header traces.
  • Run the application command in foreground debug mode if possible.

Work systematically through the layers. Test components independently:

  • Can the server reach itself on 127.0.0.1?
  • Can it reach its local gateway?
  • Can it resolve internal DNS?
  • Can it connect to the database port via nc -zv?

Step 5: Implement Fix (One Change at a Time)

Section titled “Step 5: Implement Fix (One Change at a Time)”

Never change five configuration parameters simultaneously! If the issue resolves, you won’t know which change fixed it, and you may introduce new latent bugs. Apply one atomic change, test it, and observe the result.

Confirm that:

  1. The original error symptom has disappeared.
  2. The metrics have returned to baseline.
  3. No adjacent dependencies or microservices were broken by your fix.

A bug you don’t document is a bug you will debug twice.

  • Conduct a blameless post-mortem:
    • Timeline: When was the issue introduced, detected, and mitigated?
    • Root Cause: What underlying design or configuration flaw enabled the failure?
    • Action Items: What automated tests, monitoring alerts, or architecture changes will prevent this from ever happening again?

When facing an unknown server failure, systematically investigate these 11 areas:

  • Symptoms: Server hangs on startup, kernel panic, drops to (initramfs) or emergency shell.
  • Triage Checklist:
    1. Boot into GRUB, press e, append systemd.unit=rescue.target to inspect logs.
    2. Check /etc/fstab for nonexistent UUIDs or corrupted partition labels.
    3. Run fsck on unmounted root filesystem.
    4. Inspect kernel ring buffer via journalctl -xb.
  • Symptoms: High load average, sluggish interactive terminal, worker timeouts.
  • Triage Checklist:
    Terminal window
    uptime # Compare 1/5/15 min load to nproc
    top -b -n 1 | head -n 20 # Identify runaway processes
    mpstat -P ALL 1 3 # Check if single core is pinned (single-threaded bottleneck)
    pidstat -w 1 3 # Check for excessive context switching
  • Symptoms: Services randomly dying, Redis/Node crashing, Killed message in terminal.
  • Triage Checklist:
    Terminal window
    free -h # Check available RAM vs swap
    vmstat 1 5 # Are si/so actively > 0? (Thrashing)
    sudo dmesg -T | grep -i oom # Confirm if OOM Killer terminated the process
    sudo journalctl -xe | grep -i "out of memory"
  • Symptoms: “No space left on device”, “Read-only file system”, slow database queries.
  • Triage Checklist:
    Terminal window
    df -h # Are any physical filesystems 100% full?
    df -i # Are Inodes 100% exhausted? (Zero disk bytes left, even if space looks free!)
    sudo du -sh /* 2>/dev/null | sort -h # Hunt down directory consuming space
    iostat -x -m 1 3 # Check if %util is at 100% and await > 20ms
    sudo dmesg -T | grep -i -E "ext4|xfs|io error" # Check for filesystem remounted as read-only
  • Symptoms: Cannot connect to internet, dropped packets, API gateway timeouts.
  • Triage Checklist:
    Terminal window
    ip link show # Is the interface UP?
    ip addr show # Does it have a valid IP (not 169.254.x.x)?
    ip route show # Is the default gateway configured?
    ping -c 3 8.8.8.8 # Can we reach external IP bypassing DNS?
    mtr -rw target_ip # Where along the path are packets dropping?
  • Symptoms: ping 8.8.8.8 works, but curl https://api.stripe.com fails with “Could not resolve host”.
  • Triage Checklist:
    Terminal window
    cat /etc/resolv.conf # Who is the upstream nameserver?
    dig @127.0.0.1 domain.com # Test local resolver
    dig @8.8.8.8 domain.com # Test upstream public DNS
    resolvectl status # Inspect systemd-resolved status
  • Symptoms: “Connection refused”, “Permission denied (publickey)”, session hangs.
  • Triage Checklist:
    Terminal window
    # Test with verbose debugging from client machine:
    ssh -vvv user@server_ip
    # On the server:
    sudo ss -tulpn | grep :22 # Is sshd actually listening?
    sudo systemctl status sshd # Is the daemon running?
    sudo tail -n 50 /var/log/auth.log # (or /var/log/secure on RHEL) - shows exact auth failure reason
    ls -ld ~/.ssh && ls -l ~/.ssh/authorized_keys # Are permissions strictly 700 and 600?
  • Symptoms: Service fails to start, crash-looping (auto-restart).
  • Triage Checklist:
    Terminal window
    sudo systemctl status <service_name>
    sudo journalctl -u <service_name> -n 50 --no-pager
    # Test manual binary execution using ExecStart command from service file:
    systemctl cat <service_name>
  • Symptoms: “Permission denied” when file exists and user appears to have access.
  • Triage Checklist:
    Terminal window
    ls -la /path/to/file # Check owner, group, and standard rwx
    namei -l /path/to/file # Check execute permissions across EVERY parent folder in the path!
    getfacl /path/to/file # Check if an ACL (+ sign) or mask is overriding permissions
    ls -Z /path/to/file # Check if SELinux security context is blocking access
  • Symptoms: Broken dependencies, locked apt database, corrupted RPM database.
  • Triage Checklist:
    Terminal window
    # Fix interrupted installs on Debian/Ubuntu:
    sudo dpkg --configure -a
    sudo apt --fix-broken install
    # If apt lock is stuck (ensure no apt process is running first!):
    sudo lsof /var/lib/dpkg/lock-frontend
    # Rebuild RPM database on RHEL/CentOS:
    sudo rpm --rebuilddb
  • Symptoms: Unexplained crashes or errors without clear user-facing messages.
  • Primary Log Locations:
    • /var/log/syslog or /var/log/messages: General OS system logs.
    • /var/log/auth.log or /var/log/secure: Authentication and sudo logs.
    • /var/log/dmesg or journalctl -k: Kernel logs.
    • /var/log/nginx/ or /var/log/httpd/: Web server access and error logs.
    • journalctl -p err..emerg: Query systemd journal filtered strictly for error-level logs and above.