Skip to content
Latchkey

What Is stderr? The Standard Error Stream

stderr (standard error) is the default stream a program writes its error messages and diagnostics to, kept separate from normal output on stdout.

Programs write their results to stdout and their warnings and errors to stderr. Splitting the two means you can capture clean data while still seeing problems, and it explains why some error messages still appear even when you redirect normal output to a file.

What stderr is

stderr is file descriptor 2, the channel for diagnostics. Error messages, warnings, and progress notes typically go here so they do not pollute the program's real output.

Why it is separate

Because stderr is a different stream from stdout, you can pipe a program's data onward while its errors still print to the terminal. Redirecting > only captures stdout, leaving stderr visible.

Redirecting stderr

  • cmd 2> errors.log sends stderr to a file.
  • cmd 2>&1 merges stderr into stdout.
  • cmd > out.log 2>&1 captures both streams into one file.

A common gotcha

Order matters: cmd > out.log 2>&1 works, but cmd 2>&1 > out.log does not redirect stderr to the file, because the streams are wired up left to right. This trips up many CI log-capture scripts.

stderr in CI

CI merges stdout and stderr into the job log, often interleaved. When you parse a tool's output, remember that warnings on stderr may be mixed in, so machine-readable results belong on stdout to keep them clean.

Reading failures on managed runners

Latchkey captures both streams in the job log, so error messages on stderr are right there when a step fails. Sending diagnostics to stderr keeps your stdout clean for any downstream parsing.

Key takeaways

  • stderr is the error and diagnostics stream, file descriptor 2.
  • It is separate from stdout so data and errors can be handled independently.
  • Redirection order matters: use > out 2>&1 to capture both streams.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →