Glossary · Programming

Stack Trace

A stack trace is a printed list of the function calls active when an error occurred, showing the file and line numbers that led to the failure.

Updated October 6, 2026

A stack trace (or traceback) is a report generated when an exception occurs. It lists the chain of function calls that were active at that moment, from the point of failure back toward the program's entry point, usually with file names and line numbers.

Why it matters

The stack trace is the best clue for debugging: it tells you where the error was raised and how execution got there. Reading it correctly saves time, and pasting the complete trace into a bug report or search lets others help quickly.

Example

Traceback (most recent call last):
  File "app.py", line 21, in <module>
    checkout(cart)
  File "shop.py", line 8, in checkout
    return total / cart.count
ZeroDivisionError: division by zero

In Python the last line is the error type and message, and the line just above it shows where it was raised (shop.py, line 8). In Java and JavaScript the most recent call is listed first instead.

Common mistakes

  • Reading only the first line and missing the actual error type and location.
  • Looking inside library code first; start with the frames from your own files.
  • Exposing full stack traces to visitors in production, which leaks internal paths and details.

Get notified when this term updates

Plus occasional practical tips on uptime and monitoring, nothing else. Unsubscribe anytime.

This page is general information written by our editorial team and updated when documentation changes. Servers and providers differ, so test changes safely first. See our editorial policy and disclaimer.