NG04002 Angular Origin: On your device Last updated 15 Oct 2026

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.

Exact message you may see Cannot match any routes. URL SegmentCannot match any routes. URL Segment: 'x'Uncaught (in promise): Error: NG04002NG04002: Cannot match any routes
Seen on: Angular TypeScript

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

  1. Add the route or a { path: '**', component: NotFoundComponent } fallback
  2. Use absolute links (/orders/12)
  3. Check route order and base href

Detailed fix by platform

Angular

  1. { path: 'orders/:id', component: OrderComponent } and { path: '**', component: NotFoundComponent } last
  2. Template: <a routerLink="/orders/12">

Code examples

Routes with a fallback

typescript
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

  1. URL — Exact URL segment?
  2. Routes — Is there a matching path?
  3. 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:

Where this error sits

Origin: On your device. Errors that are often confused with or caused by this one (click to open):

404 — HTTP 404 Not Found (HTTP)404Cannot find control with name — Angular: Error: Cannot find control with name: 'email' (reactive forms) (Angular)Cannot find control w…Cannot GET /route on refresh — Angular (production): Cannot GET /dashboard — 404 when refreshing or opening a deep link (Angular)Cannot GET /route on …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 (Angular)exceeded maximum budg…NG04014 — Angular: NG04014: Invalid configuration of route 'x': one of the following must be provided: component, loadComponent, redirectTo, children or loadChildren (Angular)NG04014NullInjectorError: No provider for ActivatedRoute! — Angular: NullInjectorError: No provider for ActivatedRoute! (also Router) — usually a unit test (Angular)NullInjectorError: No…Schema validation failed with the following errors — Angular CLI: Schema validation failed with the following errors: Data path "" must NOT have additional properties(xyz) (Angular)Schema validation fai…NG04002

Explore the map of this error Full error map →

🧠 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.