SoftwareSideHustles
Debugging

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

ErrorWhat it meansUsual fix
TypeError: 'NoneType' object is not subscriptableYou used [...] on NoneFind the function that returned None — often list.sort() or a missing return. Guide
AttributeError: 'NoneType' object has no attribute 'x'You used .x on NoneSame cause; re.match and find() return None when nothing matches
KeyError: 'name'The dictionary has no such keyUse d.get("name") or check "name" in d. Guide
IndexError: list index out of rangeIndex ≥ length, or the list is emptyCheck < vs <=, and handle empty lists. Guide
ModuleNotFoundError: No module named 'x'The running interpreter cannot find the packagepython -m pip install x in the right environment. Guide
ValueError: invalid literal for int() with base 10The string is not a whole numberValidate input; "4.2" and "" both fail. Guide
RuntimeError: dictionary changed size during iterationYou added/removed keys inside a loop over the dictIterate over list(d) or build a new dict. Guide
RecursionError: maximum recursion depth exceededRecursion did not stop, or input is too deepFix the base case or use a loop. Guide
json.decoder.JSONDecodeError: Expecting valueEmpty or non-JSON input (often HTML)Print the raw response first. Guide
IndentationError: unexpected indentInconsistent indentationConfigure 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 localPass x as a parameter, return the new value, or (rarely) declare global/nonlocal
UnicodeDecodeError: 'utf-8' codec can't decode byteThe file is not UTF-8, or you opened binary data as textOpen with the correct encoding, or in binary mode "rb"
TypeError: can't compare offset-naive and offset-aware datetimesMixing datetimes with and without a time zoneMake all datetimes aware. Guide

JavaScript and Node.js errors

ErrorWhat it meansUsual fix
TypeError: Cannot read properties of undefined (reading 'x')The value left of .x is undefinedData not loaded yet, wrong property name or missing await. Guide
TypeError: x is not a functionYou called something that is not a functionCheck the import (default vs named), spelling, and that you did not overwrite it
ReferenceError: x is not definedNo variable named x exists in scopeTypo, missing import, or a browser-only global (window) used in Node.js
SyntaxError: Unexpected token '<', "<!DOCTYPE"... is not valid JSONYou parsed an HTML page as JSONWrong URL, error page or login redirect. Guide
Access to fetch ... has been blocked by CORS policyThe server did not allow your originFix CORS headers on the server, or proxy. Guide
Promise { <pending> } in logsYou logged a Promise instead of awaiting itawait the call. Guide
RangeError: Maximum call stack size exceededInfinite or too-deep recursionOften a setter or getter calling itself. Guide
Error: listen EADDRINUSE: address already in use :::3000Another process holds the portStop it or use another port. Guide
Error: Cannot find module 'x'The package is not installed for this projectRun npm install in the project directory. Guide
connect ECONNREFUSED 127.0.0.1:5432Nothing is listening at that addressStart the service; inside Docker, use the service name instead of localhost
npm ERR! ERESOLVE unable to resolve dependency treePeer dependency versions conflictAlign versions; --legacy-peer-deps is a workaround, not a fix

Java errors

ErrorWhat it meansUsual fix
NullPointerException: Cannot invoke "..." because "x" is nullYou used a null referenceInitialise it or handle "not found". Guide
ArrayIndexOutOfBoundsException: Index 5 out of bounds for length 5Off-by-oneLast valid index is length - 1. Guide
ConcurrentModificationExceptionA collection changed during a for-each loopUse 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
StackOverflowErrorRecursion too deep — often generated toString/equals on bidirectional entitiesGuide
ClassNotFoundException / NoClassDefFoundErrorA class is missing at runtimeA dependency missing from the runtime classpath, or conflicting versions
java.net.BindException: Address already in useThe port is takenGuide
UnsupportedOperationException on add/sortThe list is immutable (List.of, Arrays.asList for add)Copy it into an ArrayList

Git errors

ErrorWhat it meansUsual fix
CONFLICT (content): Merge conflict in fileBoth branches changed the same linesEdit, git add, commit. Guide
! [rejected] main -> main (fetch first)The remote has commits you do notgit pull --rebase, then push
fatal: not a git repositoryYou are outside the repository foldercd into the project, or git init if it is new
Permission denied (publickey)GitHub/GitLab does not accept your SSH keyAdd your public key to your account; test with ssh -T git@github.com
error: Your local changes would be overwritten by checkoutUncommitted changes conflict with the target branchCommit or git stash first
HEAD detached at abc1234You checked out a commit, not a branchgit switch -c new-branch to keep work, or git switch main

Undoing mistakes: how to undo the last commit.

Network and HTTP errors

ErrorWhat it meansUsual fix
401 UnauthorizedMissing or invalid credentialsLog in again / refresh the token. Guide
403 ForbiddenAuthenticated but not allowedCheck permissions and roles
502 Bad GatewayA proxy got a bad response from your appThe app crashed or is not listening on the expected port
504 Gateway TimeoutThe app took longer than the proxy's timeoutSpeed up the request or move work to a background job
SSL: CERTIFICATE_VERIFY_FAILEDThe certificate chain could not be verifiedUpdate CA certificates or configure your corporate proxy's CA — do not disable verification
ETIMEDOUT / Read timed outNo response in timeCheck firewalls, DNS and whether the host is reachable; add timeouts and retries

When the error message does not help

  1. Read the full stack trace, not only the last line. How to read one.
  2. Search the exact message in quotes, removing your own file paths and variable names.
  3. Check what changed since it last worked: git diff, dependency updates, configuration, data.
  4. 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.

Cookies on this site

We use essential cookies to run the questionnaire, practice labs and sign-in. With your permission we'd also like to use analytics to understand which pages help people, and advertising cookies to measure our Google Ads. Rejecting never limits any feature. Cookie policy