Ask Steves · Daily notes · VPS, 20% off · AI Profit Lab · SEO · Money Hub

11 September 2026 · One command a day

How do I read the last 100 lines of a PM2 app's logs?

When a Node app under PM2 misbehaves, the first place to look is its output. pm2 logs appname --lines 100 prints the last 100 lines the app wrote to standard output and standard error, then keeps following the log as new lines arrive. You reach for it when a site is returning errors, an app has restarted on its own, or a deploy has gone quiet.

The command

pm2 logs appname --lines 100

pm2 logs reads the log files PM2 keeps for each process. appname is the name shown in pm2 list, and you can use the numeric id instead if you prefer. If you are not sure of the name, list your PM2 apps first. --lines 100 sets how many lines to print from each log file before following. The default is 15, which is rarely enough to see what led up to a problem. Add --err to see only the error log, --out for only the output log, or --nostream to print the lines and exit. If you started your apps with sudo, run this with sudo too, because PM2 keeps a separate set of processes and logs for each user.

What you will see

[TAILING] Tailing last 100 lines for [appname] process (change the value with --lines option)
/home/user/.pm2/logs/appname-error.log last 100 lines:
0|appname  | Error: connect ECONNREFUSED 127.0.0.1:5432
0|appname  |     at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1595:16)

/home/user/.pm2/logs/appname-out.log last 100 lines:
0|appname  | Server listening on http://127.0.0.1:3000
0|appname  | GET /api/health 200 3ms
0|appname  | GET /api/orders 500 41ms

The output comes in two sections. The error log is printed first, then the output log. Each line starts with the process id and app name, which matters when you run pm2 logs with no app name and several apps are mixed together. Read the error section for stack traces and the output section for what the app was doing at the time. There are no timestamps unless the app prints its own or you started it with --time. Once the history is shown, the command waits and prints new lines as they happen. Press Ctrl+C to stop.

When to use it

Watch out for

The command does not exit on its own. After printing the history it follows the log until you press Ctrl+C, so it will hang a script or a pipe into grep. Use --nostream when you only want the last lines. Also note that --lines 100 applies to each file, so you can see up to 200 lines in total, and the most recent output is at the bottom of the second section, not the first.

Questions people ask

Where does PM2 keep the log files?

In ~/.pm2/logs/ for the user running PM2, as appname-out.log and appname-error.log. You can open them with less or tail like any other file.

Why do the logs keep growing?

PM2 never trims its log files by default. Install the pm2-logrotate module to rotate them, or run pm2 flush appname to empty them by hand.

Reading an app's raw output is only possible on a server you control, where the process and its logs are yours to inspect. You can get the same VPS with 20% off at https://asksteves.co.uk/vps. Affiliate link.

Everything on this blog runs on one Hostinger KVM 8. This link takes 20% off the same box.

GET A VPS, 20% OFF →

Affiliate link.

More daily notes: How do I see all my Node apps running under PM2? · How do I watch the nginx error log in real time? · How do I reload nginx without dropping connections?