Error fixes
71 guides to the error messages developers hit every day. Each one quotes the exact error, gives a quick-fix checklist, explains why it happens, walks through the fix and shows how to verify it.
JavaScript errors
- TypeError: Cannot Read Properties of Undefined in JavaScript
Fix TypeError: Cannot read properties of undefined by finding which value is missing, reading the stack trace and repairing the data flow.
- TypeError: x Is Not a Function in JavaScript: Causes and Fixes
Fix TypeError: x is not a function in JavaScript: wrong imports, shadowed names, lost this, a missing semicolon or .map on a non-array.
- ReferenceError: x Is Not Defined vs undefined in JavaScript
Fix ReferenceError: x is not defined: typos, block scope, the TDZ, window or require missing in Node, and scripts that load in the wrong order.
- Fixing 'Blocked by CORS Policy' Errors in JavaScript fetch
Fix 'blocked by CORS policy' fetch errors: which headers the server must send, preflights, credentials, dev proxies and why no-cors fails.
- SyntaxError: Unexpected Token '<' in JSON: Debugging fetch
Fix SyntaxError: Unexpected token '<' in JSON from fetch: the server sent HTML. Check res.ok and content-type, then read the body as text.
- Uncaught (in promise): Fixing Unhandled Promise Rejections
Fix Uncaught (in promise) errors and Node crashes from unhandled rejections: missing await, async forEach, fire-and-forget and rethrown errors.
- RangeError: Maximum Call Stack Size Exceeded in JavaScript
Fix RangeError: Maximum call stack size exceeded: missing base cases, self-calling setters, circular data, huge spreads and deep recursion.
- Cannot Use Import Statement Outside a Module: ESM vs CommonJS
Fix SyntaxError: Cannot use import statement outside a module in Node and browsers: type module, .mjs, require of ESM and __dirname in ESM.
More on JavaScript: JavaScript interview questions
Spring Boot errors
- Spring Boot: Failed to Configure a DataSource ('url' Not Specified)
Fix 'Failed to configure a DataSource: url attribute is not specified' in Spring Boot 3 by setting the URL, adding the driver or a profile.
- Whitelabel Error Page 404 in Spring Boot: How to Fix It
Seeing the Whitelabel Error Page with status 404 in Spring Boot 3? Check the mapping, component scan, @RestController and context path.
- Spring Boot Circular Dependency: 'Beans Form a Cycle' Fix
Fix 'the dependencies of some of the beans in the application context form a cycle' in Spring Boot 3 by redesigning beans, not flags.
- Spring Boot: No Qualifying Bean of Type (Could Not Be Found)
Fix 'required a bean of type that could not be found' and 'No qualifying bean' in Spring Boot 3: scanning, conditions, qualifiers, tests.
- Web Server Failed to Start: Port 8080 Was Already in Use
Fix 'Web server failed to start. Port 8080 was already in use' in Spring Boot: find the process on the port, stop it or change server.port.
- Configuring CORS in Spring Boot: Fixing 'Blocked by CORS Policy'
Fix 'blocked by CORS policy' for a Spring Boot 3 API: global CORS config, Spring Security preflight handling, credentials and exposed headers.
- Jackson Infinite Recursion with JPA Entities in Spring Boot
Fix 'Could not write JSON: Infinite recursion (StackOverflowError)' for bidirectional JPA entities in Spring Boot 3 with DTOs or annotations.
- Spring @Autowired Field Is Null: Why Injection Didn't Happen
Why is an @Autowired or @Value field null in Spring Boot? Objects built with new, static fields and constructor timing, and how to fix them.
More on Spring Boot: Spring Boot interview questions
Java errors
- Java NullPointerException: Reading the Message and Fixing the Cause
Fix java.lang.NullPointerException by reading the helpful message, finding the null in the top stack frame and validating inputs early.
- Java ConcurrentModificationException: Removing Items Safely
Fix java.util.ConcurrentModificationException when removing items in a loop: use removeIf or Iterator.remove, and see when concurrent lists help.
- java.lang.OutOfMemoryError: Java Heap Space: Diagnosis and Fixes
Fix java.lang.OutOfMemoryError: Java heap space by checking -Xmx, capturing a heap dump and finding what retains memory in Eclipse MAT.
- ClassNotFoundException vs NoClassDefFoundError in Java
ClassNotFoundException vs NoClassDefFoundError in Java: what each error means, why classes go missing at runtime and how to fix the classpath.
- UnsupportedClassVersionError: Class File Version Mismatch in Java
Fix UnsupportedClassVersionError (class file version 65.0 vs 61.0) by matching the runtime JDK to your build or compiling with javac --release.
- UnsupportedOperationException from Arrays.asList and List.of
Why Arrays.asList and List.of throw UnsupportedOperationException on add or remove, and how to choose a mutable copy or an immutable list.
More on Java: Java interview questions
React errors
- Too Many Re-renders. React Limits the Number of Renders: How to Fix
Fix 'Too many re-renders' in React: a state setter runs during render, often onClick={setX(1)} or state synced in the component body.
- Objects Are Not Valid as a React Child: Causes and Fixes in React
Fix 'Objects are not valid as a React child' in React: rendering objects, Dates, Errors or props, plus async components on the client.
- React Invalid Hook Call: Hooks Can Only Be Called Inside a Component
Fix 'Invalid hook call' in React: hooks in class components, callbacks or plain functions, duplicate React copies and mismatched react-dom.
- React: Cannot Update a Component While Rendering a Different One
Fix the React warning 'Cannot update a component while rendering a different component': a child sets parent state during render.
- Maximum Update Depth Exceeded in React: Causes and Fixes
Fix 'Maximum update depth exceeded' in React: effects with no or unstable dependencies, setState in componentDidUpdate and ref callbacks.
- React State Not Updating Immediately After setState: How to Fix
Why React state isn't updated immediately after setState: render snapshots, batching, functional updaters, mutation and when to use useEffect.
More on React: React interview questions
TypeScript errors
- TS2532: Object Is Possibly 'undefined' (and TS18048) in TypeScript
Fix TS2532 'Object is possibly undefined' and TS18048 by finding where undefined enters the type, then narrowing or failing early.
- TS2322: Type 'X' Is Not Assignable to Type 'Y' in TypeScript
Fix TS2322 'Type X is not assignable to type Y' by reading the elaboration chain from the bottom and correcting the value, not casting.
- TS2339: Property 'x' Does Not Exist on Type 'Y' in TypeScript
Fix TS2339 'Property does not exist on type' for unions, empty objects, DOM elements and window globals without casting to any.
- TS2307: Cannot Find Module or Its Type Declarations in TypeScript
Fix TS2307 'Cannot find module or its corresponding type declarations' and TS7016 by tracing module resolution, @types, paths and exports.
- TypeScript TS2345: Not Assignable to Parameter of Type 'never'
Fix TS2345 'Argument of type string is not assignable to parameter of type never' from empty arrays, function unions and exhaustive checks.
- TS7053: Element Implicitly Has an 'any' Type in TypeScript
Fix TS7053 'Element implicitly has an any type because expression of type string can't be used to index type' with keyof, Record and guards.
More on TypeScript: TypeScript interview questions
Angular errors
- ExpressionChangedAfterItHasBeenCheckedError in Angular (NG0100)
Fix Angular NG0100 ExpressionChangedAfterItHasBeenCheckedError: why the dev-mode check fires, and data-flow fixes that beat setTimeout.
- NullInjectorError: No provider for X! in Angular (NG0201): How to Fix
Fix Angular NullInjectorError: No provider for X! (NG0201): read the injector path, add provideHttpClient(), providedIn root or a token.
- Can't bind to 'ngModel' since it isn't a known property of 'input' in Angular
Fix Angular NG8002 Can't bind to 'ngModel' since it isn't a known property of 'input': import FormsModule, then fix formControl and inputs.
- 'app-x' is not a known element in Angular (NG8001): How to Fix It
Fix Angular NG8001 'app-x' is not a known element: standalone imports, selector typos, NgModule exports, schemas and TestBed setup.
- Angular 'Blocked by CORS Policy' on ng serve: Fix with proxy.conf.json
Fix 'blocked by CORS policy' errors when Angular ng serve calls a backend: proxy.conf.json, angular.json wiring and production CORS setup.
More on Angular: Angular interview questions
Node.js errors
- Error: listen EADDRINUSE: address already in use in Node.js
Fix Node.js 'listen EADDRINUSE: address already in use :::3000': find the process holding the port, close servers on restart, use PORT and port 0.
- Error: Cannot find module in Node.js (MODULE_NOT_FOUND)
Fix Node.js 'Error: Cannot find module' and ERR_MODULE_NOT_FOUND: missing installs, wrong paths, case on Linux, ESM extensions and exports.
- npm error code ERESOLVE: Unable to Resolve Dependency Tree
Fix npm 'code ERESOLVE unable to resolve dependency tree': read the peer conflict report, upgrade the right package, use overrides with care.
- Node.js 'JavaScript heap out of memory': Reached Heap Limit Fix
Fix Node.js 'Reached heap limit Allocation failed - JavaScript heap out of memory': tell leaks from big data, take heap snapshots, stream.
- Error: connect ECONNREFUSED 127.0.0.1 in Node.js (and ::1)
Fix Node.js 'Error: connect ECONNREFUSED 127.0.0.1:5432': check the service, localhost vs ::1 since Node 17, Docker networking and startup retries.
- npm error code EACCES: Permission Denied on npm install -g
Fix 'npm error code EACCES permission denied' on global installs without sudo: change the npm prefix, use nvm or fnm, prefer npx, fix Docker.
More on Node.js: Node.js interview questions
Python errors
- ModuleNotFoundError: No module named 'x' in Python
Fix ModuleNotFoundError: No module named 'x': installs into the wrong interpreter, inactive venvs, pip vs import names and python -m.
- TypeError: 'NoneType' object is not subscriptable in Python
Fix TypeError: 'NoneType' object is not subscriptable: missing returns, list.sort(), failed re.match, dict.get and Optional type checks.
- IndentationError: expected an indented block in Python
Fix Python IndentationError: expected an indented block, unindent does not match any outer indentation level, and TabError from mixed tabs.
- UnboundLocalError: cannot access local variable in Python
Fix UnboundLocalError: cannot access local variable (once 'referenced before assignment'): why assignment makes a name local, global, nonlocal.
- KeyError in Python: Fix Missing Dictionary Keys Safely
Fix Python KeyError: 'x': d[key] vs .get, in checks, setdefault and defaultdict, JSON payload validation, pandas columns and odd key reprs.
- pip error: externally-managed-environment in Python (PEP 668)
Fix pip's error: externally-managed-environment (PEP 668) on Homebrew, Debian and Ubuntu: use a venv or pipx, not --break-system-packages.
More on Python: Python interview questions
Git & CI/CD errors
- Git fatal: refusing to merge unrelated histories (How to Fix)
Fix Git's fatal: refusing to merge unrelated histories: why it happens, when --allow-unrelated-histories is right, and safer alternatives.
- Git: failed to push some refs (fetch first, non-fast-forward)
Fix Git's error: failed to push some refs and ! [rejected] main -> main (fetch first): fetch, rebase or merge, and force-with-lease safely.
- How to Undo the Last Commit in Git: reset, amend, revert
How to undo the last commit in Git: git reset --soft, --mixed or --hard, commit --amend, git revert for pushed commits, and reflog recovery.
- Git: Your branch and 'origin/main' have diverged (Fix)
Fix 'Your branch and origin/main have diverged' and fatal: Need to specify how to reconcile divergent branches: merge, rebase or ff-only.
- Git Permission denied (publickey) on GitHub: SSH Fix
Fix git@github.com: Permission denied (publickey) and Could not read from remote repository: test SSH, load keys, set IdentityFile, or use HTTPS.
More on Git & CI/CD: Git & CI/CD interview questions
Docker errors
- Docker permission denied on /var/run/docker.sock: Fixes and Risks
Fix 'permission denied while trying to connect to the Docker daemon socket': docker group, re-login, rootless mode, contexts and a dead daemon.
- Docker 'Bind for 0.0.0.0:8080 failed: port is already allocated' Fix
Fix Docker 'port is already allocated' and 'address already in use': find the container or process on the port, then remap or bind to 127.0.0.1.
- Docker 'no space left on device': Safe Cleanup for Builds and Pulls
Fix Docker 'no space left on device' during build or pull: measure with docker system df, prune in a safe order, and cap logs and build cache.
- Docker 'exec format error': When the Image CPU Does Not Match
Fix 'exec format error' in Docker: confirm the CPU architecture mismatch with uname and docker inspect, then rebuild with the right --platform or buildx target.
- Docker Container Exits Immediately: How to Debug It
Why a Docker container exits immediately: check the exit code, read docker logs, open a shell and fix a command that only starts a background job.
More on Docker: Docker interview questions
SQL & PostgreSQL errors
- Column Must Appear in the GROUP BY Clause in PostgreSQL
Fix PostgreSQL 'column must appear in the GROUP BY clause or be used in an aggregate function' by choosing the grain, aggregates or DISTINCT ON.
- Duplicate Key Value Violates Unique Constraint in PostgreSQL
Fix PostgreSQL 'duplicate key value violates unique constraint': resync sequences after imports, use ON CONFLICT and remove check-then-insert races.
- PostgreSQL 'relation does not exist': Cause and Fix
Fix PostgreSQL 'relation does not exist': check the search_path, qualify the schema, confirm migrations ran here, and fix quoted, case-sensitive identifiers.
- PostgreSQL 'sorry, too many clients already': Cause and Fix
Fix PostgreSQL 'FATAL: sorry, too many clients already': count connections per app instance, find leaks and idle transactions, and pool safely.
- PostgreSQL 'operator does not exist': Fixing Type Mismatches
Fix PostgreSQL 'operator does not exist: integer = text': read the operand types, cast the constant or parameter, and fix the column type at the source.
More on SQL & PostgreSQL: SQL & PostgreSQL interview questions
Kubernetes errors
- Kubernetes CrashLoopBackOff: Back-off restarting failed container
Fix Kubernetes CrashLoopBackOff: read the exit code, check kubectl logs --previous, fix command, config and probes, and understand backoff timing.
- Kubernetes ImagePullBackOff: ErrImagePull, Failed to pull image
Fix Kubernetes ImagePullBackOff and ErrImagePull: read the pull error, then fix tag typos, imagePullSecrets, CPU architecture or Docker Hub rate limits.
- Kubernetes OOMKilled and Exit Code 137: Fix Memory Limits
Fix Kubernetes OOMKilled (exit code 137): read lastState.terminated.reason, tell node eviction from the container limit, and size memory limits from data.
- Kubernetes Pod Stuck in Pending: '0/3 nodes are available' Fixed
Fix a Kubernetes Pod stuck in Pending: read the '0/3 nodes are available' event, then fix requests, affinity, taints, PVCs or quotas.
- Kubernetes CreateContainerConfigError: Missing Config or Secret
Fix CreateContainerConfigError: read the kubectl describe event, repair missing ConfigMap or Secret names and keys, and use optional refs sparingly.
More on Kubernetes: Kubernetes interview questions