Angular: NG04002: Cannot match any routes. URL Segment: 'x'
The router found no route for the URL you navigated to — missing route, wrong path, or an unloaded lazy route.
Cannot match any routes. URL SegmentCannot match any routes. URL Segment: 'x'Uncaught (in promise): Error: NG04002NG04002: Cannot match any routes Meaning
Add a route for that path, or a wildcard ** fallback. Check routerLink values (leading slash), base href, route order (specific before wildcard) and that lazy children are configured with loadChildren. In SSR/hosting, also check that the server returns index.html.
Common causes
- No route defined for the path
- Typo or wrong case in
routerLink/navigate() - Wildcard route placed before specific routes
- Child routes missing
children/loadChildren <base href>wrong in a sub-folder deployment
⚡ Quick fix
- Add the route or a
{ path: '**', component: NotFoundComponent }fallback - Use absolute links (
/orders/12) - Check route order and base href
Detailed fix by platform
Angular
{ path: 'orders/:id', component: OrderComponent }and{ path: '**', component: NotFoundComponent }last- Template:
<a routerLink="/orders/12">
Code examples
Routes with a fallback
export const routes: Routes = [
{ path: '', component: HomeComponent },
{ path: 'orders/:id', component: OrderComponent },
{ path: 'admin', loadChildren: () => import('./admin/admin.routes').then(m => m.ADMIN_ROUTES) },
{ path: '**', component: NotFoundComponent }, // must be last
];How to diagnose
- URL — Exact URL segment?
- Routes — Is there a matching path?
- Order — Wildcard last?
🔧 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
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