Common Programming Errors and How to Fix Them: Python, JavaScript, Java, Git and More
A lookup table of the error messages developers search for most — what each one means in plain English, the usual cause, and the fix — with links to in-depth debugging guides.
By Software Side Hustles Editorial Team · Published · Updated · 7 min read
How to use this page: search it for the first line of your error message (Ctrl/Cmd + F). Each entry says what the error means, the most likely cause and the first thing to try. If the quick fix does not work, the linked guide walks through the other causes. For a general method that works on any bug, see how to debug code systematically.
Python errors
| Error | What it means | Usual fix |
|---|---|---|
TypeError: 'NoneType' object is not subscriptable | You used [...] on None | Find the function that returned None — often list.sort() or a missing return. Guide |
AttributeError: 'NoneType' object has no attribute 'x' | You used .x on None | Same cause; re.match and find() return None when nothing matches |
KeyError: 'name' | The dictionary has no such key | Use d.get("name") or check "name" in d. Guide |
IndexError: list index out of range | Index ≥ length, or the list is empty | Check < vs <=, and handle empty lists. Guide |
ModuleNotFoundError: No module named 'x' | The running interpreter cannot find the package | python -m pip install x in the right environment. Guide |
ValueError: invalid literal for int() with base 10 | The string is not a whole number | Validate input; "4.2" and "" both fail. Guide |
RuntimeError: dictionary changed size during iteration | You added/removed keys inside a loop over the dict | Iterate over list(d) or build a new dict. Guide |
RecursionError: maximum recursion depth exceeded | Recursion did not stop, or input is too deep | Fix the base case or use a loop. Guide |
json.decoder.JSONDecodeError: Expecting value | Empty or non-JSON input (often HTML) | Print the raw response first. Guide |
IndentationError: unexpected indent | Inconsistent indentation | Configure your editor to insert 4 spaces; do not mix tabs and spaces |
UnboundLocalError: cannot access local variable 'x' | You assign to x inside a function, so Python treats every use there as local | Pass x as a parameter, return the new value, or (rarely) declare global/nonlocal |
UnicodeDecodeError: 'utf-8' codec can't decode byte | The file is not UTF-8, or you opened binary data as text | Open with the correct encoding, or in binary mode "rb" |
TypeError: can't compare offset-naive and offset-aware datetimes | Mixing datetimes with and without a time zone | Make all datetimes aware. Guide |
JavaScript and Node.js errors
| Error | What it means | Usual fix |
|---|---|---|
TypeError: Cannot read properties of undefined (reading 'x') | The value left of .x is undefined | Data not loaded yet, wrong property name or missing await. Guide |
TypeError: x is not a function | You called something that is not a function | Check the import (default vs named), spelling, and that you did not overwrite it |
ReferenceError: x is not defined | No variable named x exists in scope | Typo, missing import, or a browser-only global (window) used in Node.js |
SyntaxError: Unexpected token '<', "<!DOCTYPE"... is not valid JSON | You parsed an HTML page as JSON | Wrong URL, error page or login redirect. Guide |
Access to fetch ... has been blocked by CORS policy | The server did not allow your origin | Fix CORS headers on the server, or proxy. Guide |
Promise { <pending> } in logs | You logged a Promise instead of awaiting it | await the call. Guide |
RangeError: Maximum call stack size exceeded | Infinite or too-deep recursion | Often a setter or getter calling itself. Guide |
Error: listen EADDRINUSE: address already in use :::3000 | Another process holds the port | Stop it or use another port. Guide |
Error: Cannot find module 'x' | The package is not installed for this project | Run npm install in the project directory. Guide |
connect ECONNREFUSED 127.0.0.1:5432 | Nothing is listening at that address | Start the service; inside Docker, use the service name instead of localhost |
npm ERR! ERESOLVE unable to resolve dependency tree | Peer dependency versions conflict | Align versions; --legacy-peer-deps is a workaround, not a fix |
Java errors
| Error | What it means | Usual fix |
|---|---|---|
NullPointerException: Cannot invoke "..." because "x" is null | You used a null reference | Initialise it or handle "not found". Guide |
ArrayIndexOutOfBoundsException: Index 5 out of bounds for length 5 | Off-by-one | Last valid index is length - 1. Guide |
ConcurrentModificationException | A collection changed during a for-each loop | Use removeIf or Iterator.remove(). Guide |
NumberFormatException: For input string: " 42" | The string is not a valid number (Java does not trim) | strip() first and validate. Guide |
StackOverflowError | Recursion too deep — often generated toString/equals on bidirectional entities | Guide |
ClassNotFoundException / NoClassDefFoundError | A class is missing at runtime | A dependency missing from the runtime classpath, or conflicting versions |
java.net.BindException: Address already in use | The port is taken | Guide |
UnsupportedOperationException on add/sort | The list is immutable (List.of, Arrays.asList for add) | Copy it into an ArrayList |
Git errors
| Error | What it means | Usual fix |
|---|---|---|
CONFLICT (content): Merge conflict in file | Both branches changed the same lines | Edit, git add, commit. Guide |
! [rejected] main -> main (fetch first) | The remote has commits you do not | git pull --rebase, then push |
fatal: not a git repository | You are outside the repository folder | cd into the project, or git init if it is new |
Permission denied (publickey) | GitHub/GitLab does not accept your SSH key | Add your public key to your account; test with ssh -T git@github.com |
error: Your local changes would be overwritten by checkout | Uncommitted changes conflict with the target branch | Commit or git stash first |
HEAD detached at abc1234 | You checked out a commit, not a branch | git switch -c new-branch to keep work, or git switch main |
Undoing mistakes: how to undo the last commit.
Network and HTTP errors
| Error | What it means | Usual fix |
|---|---|---|
401 Unauthorized | Missing or invalid credentials | Log in again / refresh the token. Guide |
403 Forbidden | Authenticated but not allowed | Check permissions and roles |
502 Bad Gateway | A proxy got a bad response from your app | The app crashed or is not listening on the expected port |
504 Gateway Timeout | The app took longer than the proxy's timeout | Speed up the request or move work to a background job |
SSL: CERTIFICATE_VERIFY_FAILED | The certificate chain could not be verified | Update CA certificates or configure your corporate proxy's CA — do not disable verification |
ETIMEDOUT / Read timed out | No response in time | Check firewalls, DNS and whether the host is reachable; add timeouts and retries |
When the error message does not help
- Read the full stack trace, not only the last line. How to read one.
- Search the exact message in quotes, removing your own file paths and variable names.
- Check what changed since it last worked:
git diff, dependency updates, configuration, data. - Reproduce in the smallest example possible. Bugs often reveal themselves while you remove unrelated code.
Frequently asked questions
Why are error messages different in each browser or version?
Engines word messages differently and improve them over time — Python 3.11+ and Java 15+ added much more precise messages. The causes are the same.
Should I just ask an AI assistant to fix the error?
It can help, but check its fix addresses the cause and does not just hide the symptom (for example, sprinkling ?. or catching and ignoring exceptions). That checking skill is valuable in its own right.
Where this skill pays off
Judging whether a proposed fix actually fixes the root cause is the heart of paid AI code-evaluation work. If you are the person on your team who can read any stack trace, see how developers earn money training AI models, or offer that skill directly through tutoring and other side hustles.