leptos-rs/leptos · error

Failed to find the route {path} requested by the user. This

Error message

Failed to find the route {path} requested by the user. This suggests that the routing rules in the Router that call this handler needs to be edited!

What it means

render_route_with_context looks up the request path in the Axum router's registered route listings and panics if the path the user requested is not among them. The message indicates the Router's routing rules and the handler's route table are out of sync — this handler was invoked for a path it has no listing for.

Source

Thrown at integrations/axum/src/lib.rs:712

        app_fn.clone(),
    );
    let asyn = render_app_async_stream_with_context(
        additional_context.clone(),
        app_fn.clone(),
    );

    move |state, req| {
        // 1. Process route to match the values in routeListing
        let path = req
            .extensions()
            .get::<MatchedPath>()
            .expect("Failed to get Axum router rule")
            .as_str();
        // 2. Find RouteListing in paths. This should probably be optimized, we probably don't want to
        // search for this every time
        let listing: &AxumRouteListing =
            paths.iter().find(|r| r.path() == path).unwrap_or_else(|| {
                panic!(
                    "Failed to find the route {path} requested by the user. \
                     This suggests that the routing rules in the Router that \
                     call this handler needs to be edited!"
                )
            });
        // 3. Match listing mode against known, and choose function
        match listing.mode() {
            SsrMode::OutOfOrder => ooo(req),
            SsrMode::PartiallyBlocked => pb(req),
            SsrMode::InOrder => io(req),
            SsrMode::Async => asyn(req),
            SsrMode::Static(_) => {
                #[cfg(feature = "default")]
                {
                    let regenerate = listing.regenerate.clone();
                    handle_static_route(
                        additional_context.clone(),
                        app_fn.clone(),

View on GitHub (pinned to 32d20f6c9d)

Solutions

  1. Register the missing path in the Axum Router / AxumRouter with the matching AxumRouteListing.
  2. Verify the requested path string exactly matches the registered route path (case, leading/trailing slashes, params).
  3. Rebuild/redeploy so server routes and client routes come from the same build.
  4. Add a fallback handler for genuinely unknown paths instead of forwarding them to render_route.

Example fix

// before
let app = Router::new().leptos_routes(&options, routes, { shell });
// routes missing the new page
// after
let routes = [AxumRouteListing::new("/new-page", Method::GET)];
let app = Router::new().leptos_routes(&options, routes, { shell }); // path now resolvable
Defensive patterns

Strategy: validation

Validate before calling

// before rendering, verify the path is registered
fn path_is_registered(paths: &[AxumRouteListing], path: &str) -> bool {
    paths.iter().any(|r| r.path() == path)
}

Try / catch

// panic from const-eval/panic! in handler cannot be caught; use a fallback route instead
let listing = paths.iter().find(|r| r.path() == path);
let listing = match listing { Some(l) => l, None => return fallback_404(req).await };

Prevention

When it happens

Trigger: A request reaches render_route/render_route_with_context whose path does not match any AxumRouteListing registered via the Router paths (typo in route, missing .path registration, catch-all forwarding unmatched paths into the handler).

Common situations: Adding a page to the client but forgetting the corresponding axum Router route; path prefix/case mismatches; wildcard routes forwarding paths that were never registered in paths(); deploying a stale server binary against a newer client route set.

Related errors


AI-assisted analysis of leptos-rs/leptos@32d20f6c9d (2026-09-01). Data as JSON: /api/errors/835bf6016f8cb3d8. Report an issue: GitHub.