
Find the Bug in 3 Lines
How to Read a Stack Trace (Without Your Eyes Glazing Over)
That wall of text is useful. Here's how to read a stack trace and find the actual bug in a few seconds, in any language.
You run your code. Red text floods the terminal. It looks like a lot, but most of it isn't for you. A stack trace is just a log of where the program was and what it was doing when it stopped. Your job is to find the part that matters.
Where to Look First
Scan the stack trace for these three things in order.
- The error message at the bottom. It tells you what kind of error happened. KeyError in Python, TypeError in JavaScript, NullPointerException in Java. That's your first clue.
- The file name. Look for the name of your script or a file you recognize. Ignore anything from language internals, standard libraries, or third party packages.
- The line number. Next to the file name, you'll see a number. That's exactly where the program crashed.
Once you have those three things, you know where to open your editor and what kind of problem to look for.
A Real Example
In Python, you might see this.
File "/home/you/project/app.py", line 12, in get_user
return user_data[user_id]
KeyError: 'delta'In JavaScript, it looks different but works the same way.
at getValue (/home/you/project/app.js:12:15)
at processUser (/home/you/project/app.js:8:10)
TypeError: Cannot read property 'state' of undefinedBoth tell you the file name, the line number, and the error. The Python one says KeyError: 'delta' (a dictionary key is missing). The JavaScript one says TypeError (something is undefined when it shouldn't be). Same structure. Different syntax.
What to Ignore
Stack traces include many lines but most are noise. Ignore lines from language internals or third party packages unless you suspect the bug is actually there. Focus only on lines pointing to files you wrote. The rest is just the program's path to the crash, not your problem.
Tags
Join the Discussion
Enjoyed this? Ask questions, share your take (hot, lukewarm, or undecided), or follow the thread with people in real time. The community’s open, join us.
Latest in Beginner Guides

How to Read a Stack Trace (Without Your Eyes Glazing Over)
Apr 8, 2026

What Is an API? A Visual Guide to How Apps Talk to Each Other
Mar 9, 2026

Learning SQL With a Small Dataset
Feb 10, 2026

Top Programming Languages Worth Learning in 2026
Jan 22, 2026

React or Not? Picking a Frontend Framework in 2026
Jan 21, 2026
Right Now in Tech

Apple Discontinues Mac Pro, Ends Intel Era
Mar 27, 2026

OpenAI Is Pulling the Plug on Sora
Mar 26, 2026

Meta and YouTube Ordered to Pay $3M in Landmark Social Media Ruling
Mar 25, 2026

Your Galaxy S26 Can Finally AirDrop to an iPhone
Mar 23, 2026

Jury: Musk Misled Twitter Shareholders to Get Lower Price
Mar 21, 2026