Operations · 8 min read · Intermediate
Debugging Live Services with journalctl
Inspect service logs, filter by time window, and diagnose 502 Bad Gateway errors calmly.
What you'll learn
- Stream live logs with `journalctl -u <unit> -f`
- Inspect recent failures with `--since "15 minutes ago"`
- Check `/var/log/nginx/error.log` for upstream timeouts or permission errors
Overview
Inspect service logs, filter by time window, and diagnose 502 Bad Gateway errors calmly.
Code Example
# Follow live logs for your API
journalctl -u devpath-api -f
# Check the last 100 lines and Nginx error log
journalctl -u devpath-api -n 100 --no-pager
tail -n 50 /var/log/nginx/error.log
Key Takeaways
- Stream live logs with
journalctl -u <unit> -f - Inspect recent failures with
--since "15 minutes ago" - Check
/var/log/nginx/error.logfor upstream timeouts or permission errors
Quick Check
Check Your Understanding
Score: 0 / 1
1. What usually causes an Nginx `502 Bad Gateway` response?
Study Workspace
Finished this lesson?
Your progress is saved locally in your browser, no account needed.