Troubleshoot Linux App Startup With journalctl
In this article
When a Linux application fails to start, the fastest way to find out why is to read its log output with journalctl. This command queries the systemd journal, which collects logs from services, applications, and the kernel. You can filter by service name, executable path, or time range to see exactly what error occurred during startup. This guide assumes you are using a systemd-based distribution (most modern ones, including Ubuntu, Debian, Fedora, and Arch) and that your app is launched either as a systemd service or from the command line.
What You'll Need
- A terminal window with sudo or root access (some journalctl options require it).
- The name of the application or service you are troubleshooting (e.g.,
nginx,myapp.service, or the full path to the executable). - Basic familiarity with the command line and reading log output.
Step-by-Step
- Identify the exact unit name or executable. If your app runs as a systemd service, find its unit name with
systemctl list-units --type=service | grep -i your-appor checksystemctl status your-app.service. If it's a GUI app or a command-line program, note the binary name (e.g.,firefox,myapp). - View recent logs for the app. Run
journalctl -u your-app.service(replace with the actual unit name) to see all logs from that service. For a non-service app, usejournalctl _COMM=your-apporjournalctl /path/to/executable. If you just tried to start it, add-n 50to show the last 50 lines:journalctl -u your-app.service -n 50. - Filter by time to isolate the startup attempt. If the log is long, limit it to the last few minutes:
journalctl -u your-app.service --since "5 minutes ago"or--since today. For a precise window, use--since "2025-01-01 10:00:00" --until "2025-01-01 10:05:00". - Look for error lines. Scan the output for lines containing
error,failed,cannot,permission denied, orsegfault. These usually point to the root cause, such as a missing config file, a port already in use, or a library not found. - Check the priority level. Use
-p errto show only errors and higher:journalctl -u your-app.service -p err -n 20. This filters out informational messages and makes problems stand out. - Add verbose output if needed. If the log is cryptic, restart the app with verbose or debug flags (check the app's help with
--helpor-v) and then check the journal again. For systemd services, you can also runjournalctl -u your-app.service -o verboseto see structured metadata like process IDs and source files. - Correlate with kernel messages. If the app crashes hard, check
journalctl -k -n 30for kernel messages (e.g., segfaults, OOM kills). This can reveal memory issues or hardware problems. - Confirm the fix. After making changes (e.g., editing a config file, installing a dependency), restart the app and run
journalctl -u your-app.service --since "1 minute ago"again to see if new errors appear or if the startup succeeds.
Common Mistakes
- Using the wrong unit name. If you guess the service name, you'll get no output. Always verify with
systemctl statusorsystemctl list-units. - Not using sudo when needed. Some journal entries are restricted to root. If you see "No journal files were found" or permission errors, prepend
sudo. - Ignoring timestamps. Logs from previous runs can confuse you. Always filter by time to focus on the most recent startup attempt.
- Forgetting that GUI apps may not log to journald. Some desktop apps write to their own log files (e.g., in
~/.local/share/or~/.config/). If journalctl shows nothing, check those locations. - Assuming journalctl shows stdout/stderr. By default, systemd captures stdout and stderr for services, but for user applications launched from a terminal, the output goes to the terminal, not the journal. You need to run such apps from a terminal to see errors, or use
systemd-runto launch them under journald.
Tips
- Use
journalctl -f(follow mode) to watch logs in real time while you attempt to start the app in another terminal. This shows the error as it happens. - Combine filters:
journalctl -u myapp.service -p warning --since "30 minutes ago"shows warnings and errors from the last half hour. - If you manage multiple servers, remember that journald persists logs only if
Storage=persistentis set in/etc/systemd/journald.conf. Otherwise, logs are lost on reboot. - For services,
systemctl status your-app.serviceshows the last few log lines directly, which is quicker than typing journalctl. - If the app is a user service (started with
systemctl --user), add--userto journalctl:journalctl --user -u myapp.service.
Troubleshooting
If journalctl shows no logs at all for your app, try these steps:
- Verify the service exists. Run
systemctl list-units | grep your-app. If it doesn't appear, the service may not be installed or enabled. - Check if the app is a user process. If it's a GUI app launched from a desktop environment, it may not be in the system journal. Run it from a terminal and observe the output directly.
- Ensure journald is running. Check with
systemctl status systemd-journald. If it's not active, start it withsudo systemctl start systemd-journald. - Look for separate log files. Many apps log to
/var/log/(e.g.,/var/log/nginx/error.log). Usels /var/log/and inspect relevant files. - If the app segfaults, install debugging symbols. For example, on Ubuntu,
sudo apt install app-dbgsym(if available) and then usecoredumpctlto analyze the core dump:coredumpctl info your-app.
Frequently Asked Questions
Why does journalctl show nothing for my app?
If the app is not a systemd service and was not launched via systemd, its output goes to the terminal, not the journal. Run it from a terminal to see errors. Also, user sessions may require journalctl --user to see user service logs.
How do I see logs from the last boot?
Use journalctl -b -1 for the previous boot, -b -2 for the one before that, and so on. Without -b, you see the current boot only.
Can I filter by a specific process ID?
Yes, use journalctl _PID=1234. You can find the PID with pgrep your-app or from systemctl status.
What does "No journal files were found" mean?
It means the journal has no stored entries, often because journald is not running or storage is volatile. Check systemctl status systemd-journald and consider setting Storage=persistent in /etc/systemd/journald.conf.
How do I permanently save journal logs across reboots?
Edit /etc/systemd/journald.conf, set Storage=persistent, then restart journald with sudo systemctl restart systemd-journald. Logs will be stored in /var/log/journal/.
Is journalctl the same as syslog?
No. journalctl reads the systemd journal, while syslog is a separate logging system. Some systems forward journal entries to syslog, but not all. Check /var/log/syslog or /var/log/messages if you need syslog data.