Angular: NG0955: The provided track expression resulted in duplicated keys for a given collection (@for)
In an @for block (or trackBy), two items produced the same tracking key, so Angular cannot match them to DOM nodes reliably.
NG0955: The provided track expression resulted in duplicated keysThe provided track expression resulted in duplicated keys for a given collectionduplicated keys for a given collection Meaning
track must return a unique, stable value per item (an id). Duplicate keys — or tracking by a non-unique field or $index of changing lists — make Angular reuse the wrong nodes, causing glitches and the NG0955 warning. A related warning NG0956 reports a full list re-creation when keys change.
Common causes
- Tracking by a field that is not unique (name, category)
- Items really contain duplicate ids from the API
track $indexon a list that reorders or filters- Generating new ids on every render (
Math.random()) - Merging two lists without deduplication
⚡ Quick fix
- Track by a unique id:
track item.id - Deduplicate data before rendering
- Avoid random or index-based keys on dynamic lists
Detailed fix by platform
Angular
@for (u of users; track u.id) { ... }- Check duplicates:
new Set(users.map(u => u.id)).size !== users.length
Code examples
Unique keys
@for (u of users; track u.id) { <!-- u.id must be unique and stable -->
<app-user-row [user]="u" />
} @empty {
<p>No users</p>
}How to diagnose
- Key — What does track return?
- Data — Are ids unique in the response?
- List — Does it reorder or refilter?
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
- Cannot find control with name Angular: Error: Cannot find control with name: 'email' (reactive forms)
- Could not find the builder's node package Angular CLI: Could not find the '@angular-devkit/build-angular:browser' builder's node package / Cannot find module '@angular-devkit/build-angular/package.json'
- exceeded maximum budget Angular build: Error: bundle initial exceeded maximum budget. Budget 1.00 MB was not met by 120.00 kB with a total of 1.12 MB
Most viewed in Angular
Other ways to find it
Where this error sits
Origin: On your device. Errors that are often confused with or caused by this one (click to open):
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Report a correction or suggest an improvement
Last updated 15 Oct 2026