# Angular: NG04002: Cannot match any routes. URL Segment: 'x'

**Code:** `NG04002` · **Category:** Angular · **Seen on:** Angular, TypeScript

The router found no route for the URL you navigated to — missing route, wrong path, or an unloaded lazy route.

## 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?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/angular/ng04002-cannot-match-any-routes)
